From 4c62ccce713c416ecdef1166246565e61595dd57 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Tue, 16 May 2023 18:51:30 +0100 Subject: [PATCH] phpcs --- .../core/Mage/Catalog/Model/Resource/Url.php | 20 ++++++------- app/code/core/Mage/Catalog/Model/Url.php | 30 +++++++++---------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/app/code/core/Mage/Catalog/Model/Resource/Url.php b/app/code/core/Mage/Catalog/Model/Resource/Url.php index c61d44cfdc1..010a0a2045f 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Url.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Url.php @@ -1185,7 +1185,6 @@ protected function getSelectToClearRewrites($adapter, $storeId) ->where('tur.is_system = 1'); if ($createUrlForDisabled) { - // Find rewrites for cartegory/product $select->where('tur.category_id IS NOT NULL') ->where('tur.product_id IS NOT NULL'); @@ -1194,13 +1193,12 @@ protected function getSelectToClearRewrites($adapter, $storeId) // (either to other category or deleted), so rewrite "category_id-product_id" is invalid if ($productUseCategories) { $select->joinLeft( - ['tcp' => $this->getTable('catalog/category_product')], - 'tur.category_id = tcp.category_id AND tur.product_id = tcp.product_id', - [] - ) + ['tcp' => $this->getTable('catalog/category_product')], + 'tur.category_id = tcp.category_id AND tur.product_id = tcp.product_id', + [] + ) ->where('tcp.category_id IS NULL'); } - } else { // Find products, cartegories and cartegory/product rewrites for disabled products or cartegories $productTable = $this->getTable(['catalog/product', 'int']); @@ -1209,7 +1207,7 @@ protected function getSelectToClearRewrites($adapter, $storeId) ['cpei' => $productTable], 'cpei.entity_id = tur.product_id AND cpei.attribute_id = :product_status_attribute_id', [] - ) + ) ->joinLeft( ['ccei1' => $categoryTable], 'ccei1.attribute_id = :is_active_category_attribute_id AND ccei1.store_id = 0 AND ccei1.entity_id = tur.category_id', @@ -1219,14 +1217,14 @@ protected function getSelectToClearRewrites($adapter, $storeId) ['ccei2' => $categoryTable], 'ccei2.attribute_id = :is_active_category_attribute_id AND ccei2.store_id = :store_id AND ccei2.entity_id = tur.category_id', [] - ); + ); $productStatusAttributeId = Mage::getSingleton('eav/config') ->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'status'); $bind['product_status_attribute_id'] = $productStatusAttributeId->getId(); - $isActiveCategoryAttribute = Mage::getSingleton('eav/config') - ->getAttribute(Mage_Catalog_Model_Category::ENTITY, 'is_active'); - $bind['is_active_category_attribute_id'] = $isActiveCategoryAttribute->getId(); + $isActiveCategoryAttribute = Mage::getSingleton('eav/config') + ->getAttribute(Mage_Catalog_Model_Category::ENTITY, 'is_active'); + $bind['is_active_category_attribute_id'] = $isActiveCategoryAttribute->getId(); // product_is_disabled OR (category is disabled) OR (cartegory/product rewrite) $where = '(cpei.value = 2 OR (IF(ccei2.value_id > 0, ccei2.value, ccei1.value) = 0) OR (tur.category_id IS NOT NULL AND tur.product_id IS NOT NULL) )'; diff --git a/app/code/core/Mage/Catalog/Model/Url.php b/app/code/core/Mage/Catalog/Model/Url.php index 65e6ae20f59..fc7145edf06 100644 --- a/app/code/core/Mage/Catalog/Model/Url.php +++ b/app/code/core/Mage/Catalog/Model/Url.php @@ -36,8 +36,8 @@ class Mage_Catalog_Model_Url */ public const ALLOWED_REQUEST_PATH_OVERFLOW = 10; - const XML_PATH_PRODUCT_USE_CATEGORIES = 'catalog/seo/product_use_categories'; - const XML_PATH_CREATE_URL_FOR_DISABLED = 'catalog/seo/create_url_for_disabled'; + public const XML_PATH_PRODUCT_USE_CATEGORIES = 'catalog/seo/product_use_categories'; + public const XML_PATH_CREATE_URL_FOR_DISABLED = 'catalog/seo/create_url_for_disabled'; /** * Resource model @@ -542,25 +542,25 @@ public function refreshProductRewrites($storeId) } } - if ($loadCategories) { - foreach ($this->getResource()->getCategories($loadCategories, $storeId, $createForDisabled) as $category) { - $this->_categories[$category->getId()] = $category; - } + if ($loadCategories) { + foreach ($this->getResource()->getCategories($loadCategories, $storeId, $createForDisabled) as $category) { + $this->_categories[$category->getId()] = $category; } } + } - foreach ($products as $product) { - $this->_refreshProductRewrite($product, $this->_categories[$storeRootCategoryId]); - if ($productUseCategories) { - foreach ($product->getCategoryIds() as $categoryId) { - if ($categoryId != $storeRootCategoryId && isset($this->_categories[$categoryId])) { - if (strpos($this->_categories[$categoryId]['path'], $storeRootCategoryPath . '/') !== 0) { - continue; - } - $this->_refreshProductRewrite($product, $this->_categories[$categoryId]); + foreach ($products as $product) { + $this->_refreshProductRewrite($product, $this->_categories[$storeRootCategoryId]); + if ($productUseCategories) { + foreach ($product->getCategoryIds() as $categoryId) { + if ($categoryId != $storeRootCategoryId && isset($this->_categories[$categoryId])) { + if (strpos($this->_categories[$categoryId]['path'], $storeRootCategoryPath . '/') !== 0) { + continue; } + $this->_refreshProductRewrite($product, $this->_categories[$categoryId]); } } + } unset($products); $this->_rewrites = [];