Skip to content

Commit

Permalink
phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed May 16, 2023
1 parent a11f82e commit 4c62ccc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
20 changes: 9 additions & 11 deletions app/code/core/Mage/Catalog/Model/Resource/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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']);
Expand All @@ -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',
Expand All @@ -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) )';
Expand Down
30 changes: 15 additions & 15 deletions app/code/core/Mage/Catalog/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = [];
Expand Down

0 comments on commit 4c62ccc

Please sign in to comment.