Skip to content

Commit

Permalink
Short array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinNowakMacopedia committed Oct 11, 2022
1 parent 41a5a2d commit 90bc24f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions app/code/core/Mage/Catalog/Model/Indexer/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,19 @@ protected function _registerProductEvent(Mage_Index_Model_Event $event)
$dataChange = false;
$products = [];

if (is_a($product, Mage_Catalog_Model_Product_Action::class)) {
if ($product instanceof Mage_Catalog_Model_Product_Action) {
$attributesData = $product->getData('attributes_data');
$productsIds = $product->getData('product_ids');
$dataChange = isset($attributesData['status']) && isset($productsIds) && count($productsIds) > 0;
if ($dataChange) {
$products = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('entity_id', array('in'=> $productsIds));
->addFieldToFilter('entity_id', ['in'=> $productsIds]);
} else {
return;
}
}

if (is_a($product, Mage_Catalog_Model_Product::class)) {
if ($product instanceof Mage_Catalog_Model_Product) {
$dataChange =
(
$product->dataHasChangedFor('url_key')
Expand Down
26 changes: 13 additions & 13 deletions app/code/core/Mage/Catalog/Model/Resource/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ public function clearRewrites($storeId)

$rewriteIds = $adapter->fetchCol($select, $bind);
if ($rewriteIds) {
$where = array($this->getIdFieldName() . ' IN(?)' => $rewriteIds);
$where = [$this->getIdFieldName() . ' IN(?)' => $rewriteIds];
$adapter->delete($this->getMainTable(), $where);
}

Expand Down Expand Up @@ -1136,7 +1136,7 @@ public function clearDisabledCategory($categoryId, $storeId = null)

$adapter = $this->_getWriteAdapter();

$table = $this->getTable(array('catalog/category', 'int'));
$table = $this->getTable(['catalog/category', 'int']);
$select = $adapter->select()
->from(['tur' => $this->getMainTable()], $this->getIdFieldName())
->joinLeft(
Expand Down Expand Up @@ -1185,7 +1185,7 @@ protected function getSelectToClearRewrites($adapter, $storeId)

$bind = ['store_id' => $storeId];
$select = $adapter->select()
->from(array('tur' => $this->getMainTable()), $this->getIdFieldName())
->from(['tur' => $this->getMainTable()], $this->getIdFieldName())
->where('tur.store_id = :store_id')
->where('tur.is_system = 1');

Expand All @@ -1199,31 +1199,31 @@ protected function getSelectToClearRewrites($adapter, $storeId)
// (either to other category or deleted), so rewrite "category_id-product_id" is invalid
if ($productUseCategories) {
$select->joinLeft(
array('tcp' => $this->getTable('catalog/category_product')),
['tcp' => $this->getTable('catalog/category_product')],
'tur.category_id = tcp.category_id AND tur.product_id = tcp.product_id',
array()
[]
)
->where('tcp.category_id IS NULL');
}

} else {
// Find products, cartegories and cartegory/product rewrites for disabled products or cartegories
$productTable = $this->getTable(array('catalog/product', 'int'));
$categoryTable = $this->getTable(array('catalog/category', 'int'));
$productTable = $this->getTable(['catalog/product', 'int']);
$categoryTable = $this->getTable(['catalog/category', 'int']);
$select->joinLeft(
['cpei' => $productTable],
'cpei.entity_id = tur.product_id AND cpei.attribute_id = :product_status_attribute_id',
[]
)
->joinLeft(
array('ccei1' => $categoryTable),
['ccei1' => $categoryTable],
'ccei1.attribute_id = :is_active_category_attribute_id AND ccei1.store_id = 0 AND ccei1.entity_id = tur.category_id',
array()
[]
)
->joinLeft(
array('ccei2' => $categoryTable),
['ccei2' => $categoryTable],
'ccei2.attribute_id = :is_active_category_attribute_id AND ccei2.store_id = :store_id AND ccei2.entity_id = tur.category_id',
array()
[]
);
$productStatusAttributeId = Mage::getSingleton('eav/config')
->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'status');
Expand All @@ -1240,9 +1240,9 @@ protected function getSelectToClearRewrites($adapter, $storeId)
if ($productUseCategories) {
$select
->joinLeft(
array('tcp' => $this->getTable('catalog/category_product')),
['tcp' => $this->getTable('catalog/category_product')],
'tcp.category_id = tur.category_id AND tcp.product_id = tur.product_id',
array()
[]
);
// product_is_disabled OR (category is disabled) OR (cartegory/product rewrite AND product were moved away from the category)
$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 AND tcp.category_id IS NULL))';
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public function refreshProductRewrite($productId, $storeId = null)
$product = $this->getResource()->getProduct($productId, $storeId, $this->createForDisabled);
if (!$product) {
// Product doesn't belong to this store - clear all its url rewrites including root one
$this->getResource()->clearProductRewrites($productId, $storeId, array());
$this->getResource()->clearProductRewrites($productId, $storeId, []);
return $this;
}

Expand Down

0 comments on commit 90bc24f

Please sign in to comment.