Skip to content

Commit

Permalink
Merge pull request PrestaShop#33587 from jolelievre/remove-old-produc…
Browse files Browse the repository at this point in the history
…t-page

Clean old product page code
  • Loading branch information
Hlavtox authored Dec 19, 2023
2 parents 13d49b8 + c996ce0 commit f04e638
Show file tree
Hide file tree
Showing 164 changed files with 719 additions and 30,343 deletions.
2 changes: 1 addition & 1 deletion admin-dev/themes/new-theme/js/fos_js_routes.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default class OrderViewPage {
$item.find(OrderViewPageMap.productPackModal.product.name).html(item.name);
$item.find(OrderViewPageMap.productPackModal.product.link).attr(
'href',
this.router.generate('admin_product_form', {id: item.id}),
this.router.generate('admin_products_edit', {productId: item.id}),
);
if (item.reference !== '') {
$item.find(OrderViewPageMap.productPackModal.product.ref).append(item.reference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class FeatureValuesManager {
private watchFeatureSelectors(): void {
$(this.$collectionContainer).on('change', ProductMap.featureValues.featureSelect, (event) => {
const $selector = $(event.target);
const idFeature = Number($selector.val());
const featureId = Number($selector.val());
const $collectionRow = $selector.closest(ProductMap.featureValues.collectionRow);
const $featureValueSelector = $(ProductMap.featureValues.featureValueSelect, $collectionRow).first();
const $customValueInputs = $(ProductMap.featureValues.customValueInput, $collectionRow);
Expand All @@ -131,18 +131,18 @@ export default class FeatureValuesManager {
$featureValueSelector.val('0');
$customFeatureIdInput.val('');

this.renderFeatureValueChoices($featureValueSelector, idFeature);
this.renderFeatureValueChoices($featureValueSelector, featureId);
});
}

private renderFeatureValueChoices($featureValueSelector: JQuery, idFeature: number): void {
if (!idFeature) {
private renderFeatureValueChoices($featureValueSelector: JQuery, featureId: number): void {
if (!featureId) {
$featureValueSelector.prop('disabled', true);

return;
}

$.get(this.router.generate('admin_feature_get_feature_values', {idFeature}))
$.get(this.router.generate('admin_feature_get_feature_values', {featureId}))
.then((featureValuesData) => {
$featureValueSelector.prop('disabled', featureValuesData.length === 0);
$featureValueSelector.empty();
Expand Down
1 change: 0 additions & 1 deletion app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ twig:
form_themes:
- '@PrestaShop/Admin/TwigTemplateForm/bootstrap_4_horizontal_layout.html.twig'
paths:
'%admin_page%/Product': Product
'%admin_page%/TwigTemplateForm': Twig
'%admin_page%/Common': Common
'%admin_page%/Configure/AdvancedParameters': AdvancedParameters
Expand Down
39 changes: 0 additions & 39 deletions classes/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use PrestaShop\PrestaShop\Core\Exception\CoreException;
use PrestaShop\PrestaShop\Core\Feature\TokenInUrls;
use PrestaShopBundle\Routing\Converter\LegacyUrlConverter;
use PrestaShopBundle\Service\TransitionalBehavior\AdminPagePreferenceInterface;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
Expand Down Expand Up @@ -760,44 +759,6 @@ public function getAdminLink($controller, $withToken = true, $sfRouteParams = []

$routeName = '';
switch ($controller) {
case 'AdminProducts':
// New architecture modification: temporary behavior to switch between old and new controllers.
/** @var AdminPagePreferenceInterface $pagePreference */
$pagePreference = $sfContainer->get('prestashop.core.admin.page_preference_interface');
$redirectLegacy = $pagePreference->getTemporaryShouldUseLegacyPage('product');
if (!$redirectLegacy) {
if (array_key_exists('id_product', $sfRouteParams)) {
if (array_key_exists('deleteproduct', $sfRouteParams)) {
return $sfRouter->generate(
'admin_product_unit_action',
['action' => 'delete', 'id' => $sfRouteParams['id_product']]
);
}
//default: if (array_key_exists('updateproduct', $sfRouteParams))
return $sfRouter->generate(
'admin_product_form',
['id' => $sfRouteParams['id_product']]
);
}
if (array_key_exists('submitFilterproduct', $sfRouteParams)) {
$routeParams = [];
if (array_key_exists('filter_column_sav_quantity', $sfRouteParams)) {
$routeParams['quantity'] = $sfRouteParams['filter_column_sav_quantity'];
}
if (array_key_exists('filter_column_active', $sfRouteParams)) {
$routeParams['active'] = $sfRouteParams['filter_column_active'];
}

return $sfRouter->generate('admin_product_catalog_filters', $routeParams);
}

return $sfRouter->generate('admin_product_catalog', $sfRouteParams);
} else {
$params = array_merge($params, $sfRouteParams);
}

break;

case 'AdminTranslations':
// In case of email body translations we want to get a link to legacy controller,
// in other cases - it's the migrated controller
Expand Down
22 changes: 4 additions & 18 deletions classes/QuickAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Core\FeatureFlag\FeatureFlagSettings;
use PrestaShop\PrestaShop\Core\FeatureFlag\FeatureFlagStateCheckerInterface;

/**
* Class QuickAccessCore.
*/
Expand All @@ -50,7 +46,7 @@ class QuickAccessCore extends ObjectModel
/**
* link to new product creation form for product v2
*/
private const NEW_PRODUCT_V2_LINK = 'index.php/sell/catalog/products-v2/create';
private const NEW_PRODUCT_V2_LINK = 'index.php/sell/catalog/products/create';

/**
* @see ObjectModel::$definition
Expand Down Expand Up @@ -127,11 +123,9 @@ public static function getQuickAccessesWithToken($idLang, $idEmployee)
unset($quickAccess[$index]);
continue;
}
// if new product page feature is enabled we create new product v2 modal popup
if (self::productPageV2Enabled()) {
$quickAccess[$index]['link'] = $context->link->getAdminBaseLink() . basename(_PS_ADMIN_DIR_) . '/' . self::NEW_PRODUCT_V2_LINK;
$quickAccess[$index]['class'] = 'new-product-button';
}
// We create new product v2 modal popup link
$quickAccess[$index]['link'] = $context->link->getAdminBaseLink() . basename(_PS_ADMIN_DIR_) . '/' . self::NEW_PRODUCT_V2_LINK;
$quickAccess[$index]['class'] = 'new-product-button';
}
}

Expand Down Expand Up @@ -163,12 +157,4 @@ public function toggleNewWindow()

return $this->update(false);
}

/**
* @return bool
*/
private static function productPageV2Enabled(): bool
{
return SymfonyContainer::getInstance()->get(FeatureFlagStateCheckerInterface::class)->isEnabled(FeatureFlagSettings::FEATURE_FLAG_PRODUCT_PAGE_V2);
}
}
6 changes: 1 addition & 5 deletions classes/helper/HelperList.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
use PrestaShop\PrestaShop\Adapter\Routing\AdminLinkBuilder;
use PrestaShop\PrestaShop\Adapter\Routing\LegacyHelperLinkBuilder;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Core\Routing\EntityLinkBuilderFactory;
use PrestaShop\PrestaShop\Core\Routing\Exception\BuilderNotFoundException;

Expand Down Expand Up @@ -612,10 +611,7 @@ public function displayDeleteLink($token, $id, $name = null)
switch ($this->currentIndex) {
case 'index.php?controller=AdminProducts':
case 'index.php?tab=AdminProducts':
// New architecture modification: temporary behavior to switch between old and new controllers.
$pagePreference = SymfonyContainer::getInstance()->get('prestashop.core.admin.page_preference_interface');
$redirectLegacy = $pagePreference->getTemporaryShouldUseLegacyPage('product');
if (!$redirectLegacy && $this->identifier == 'id_product') {
if ($this->identifier == 'id_product') {
$href = Context::getContext()->link->getAdminLink('AdminProducts', true, ['id_product' => $id, 'deleteproduct' => 1]);
}

Expand Down
17 changes: 0 additions & 17 deletions classes/lang/KeysReference/FeatureFlagLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

// Product feature flag in 1.7.8
trans('Experimental product page', 'Admin.Advparameters.Feature');
trans(
'This page benefits from increased performance and includes new features such as a new combination management system. Please note this is a work in progress and some features are not available yet.',
'Admin.Advparameters.Help'
);

// Product feature flag in 8.0
trans('New product page - Single store', 'Admin.Advparameters.Feature');
// Product feature flag in 8.1
trans('New product page', 'Admin.Advparameters.Feature');
trans('This page benefits from increased performance and includes new features such as a new combination management system.', 'Admin.Advparameters.Help');

// Product multi store feature flag in 8.0
trans('New product page - Multistore', 'Admin.Advparameters.Feature');
trans('Access the new product page, even in a multistore context. This is a work in progress and some features are not available.', 'Admin.Advparameters.Help');

// Legacy link feature flags
trans('Attribute groups', 'Admin.Advparameters.Feature');
trans('Enable or disable the migrated attribute page.', 'Admin.Advparameters.Help');
Expand Down
Loading

0 comments on commit f04e638

Please sign in to comment.