Skip to content

Commit

Permalink
Revert "Fixed Mage_Catalog_Model_Product_Status::addSaleableFilterToC…
Browse files Browse the repository at this point in the history
…ollection() which didn't do anything (#2603)"

This reverts commit eb27bfa.
  • Loading branch information
fballiano authored Oct 17, 2022
1 parent 15f83af commit ab64ebe
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,13 @@ protected function _prepareCollection()
->setStore($this->getStore())
->addAttributeToSelect($attributes)
->addAttributeToSelect('sku')
->addAttributeToSelect('gift_message_available')
->addStoreFilter()
->addAttributeToFilter('type_id', array_keys(
Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()
))
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds()
]);
->addAttributeToSelect('gift_message_available');

Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);

$this->setCollection($collection);
return parent::_prepareCollection();
Expand Down
10 changes: 4 additions & 6 deletions app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@ protected function _getCustomers()
protected function _getProducts()
{
if (!$this->_productCollection) {
$this->_productCollection = Mage::getResourceModel('catalog/product_collection');
$this->_productCollection= Mage::getResourceModel('catalog/product_collection');
//$this->_productCollection->getEntity()->setStore($this->_getStore());
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_productCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($this->_productCollection);
$this->_productCollection
->addAttributeToSelect('name')
$this->_productCollection->addAttributeToSelect('name')
->addAttributeToSelect('sku')
->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds()
])
->load();
}
return $this->_productCollection->getItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ protected function _prepareCollection()
->addAttributeToSelect('attribute_set_id')
->addAttributeToFilter('type_id', ['in' => $this->getAllowedSelectionTypes()])
->addFilterByRequiredOptions()
->addStoreFilter()
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds()
]);
->addStoreFilter();

if ($products = $this->_getProducts()) {
$collection->addIdFilter($this->_getProducts(), true);
Expand All @@ -83,6 +80,8 @@ protected function _prepareCollection()
$this->setEmptyText($this->__('Please enter search conditions to view products.'));
}

Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);

$this->setCollection($collection);

return parent::_prepareCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ protected function _prepareData()
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addAttributeToSort('position', 'asc')
->addStoreFilter()
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds()
])
->addMinimalPrice()

->joinTable('bundle/option', 'parent_id=entity_id', ['option_id' => 'option_id'])
->joinTable('bundle/selection', 'option_id=option_id', ['product_id' => 'product_id'], '{{table}}.product_id='.$this->getProduct()->getId());

Expand All @@ -55,6 +53,7 @@ protected function _prepareData()
$collection->addIdFilter(Mage::getSingleton('checkout/cart')->getProductIds(), true);
}

Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
$collection->getSelect()->group('entity_id');

Expand Down
16 changes: 8 additions & 8 deletions app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ class Mage_Catalog_Block_Seo_Sitemap_Product extends Mage_Catalog_Block_Seo_Site
*/
protected function _prepareLayout()
{
/** @var Mage_Catalog_Model_Resource_Product_Collection $collection */
$collection = Mage::getModel('catalog/product')->getCollection();
$collection
->addAttributeToSelect('name')
->addAttributeToSelect('url_key')
->addStoreFilter()
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds()
]);
/** @var Mage_Catalog_Model_Resource_Product_Collection $collection */

$collection->addAttributeToSelect('name');
$collection->addAttributeToSelect('url_key');
$collection->addStoreFilter();

Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

$this->setCollection($collection);

return $this;
}

Expand Down
7 changes: 3 additions & 4 deletions app/code/core/Mage/Catalog/Model/Layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ public function prepareProductCollection($collection)
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addPriceData()
->addTaxPercents()
->addUrlRewrite($this->getCurrentCategory()->getId())
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds()
]);
->addUrlRewrite($this->getCurrentCategory()->getId());

Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/CatalogIndex/Model/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function plainReindex($products = null, $attributes = null, $stores = nul
$collection = $this->_getProductCollection($store, $products);
$collection->addAttributeToFilter(
'status',
['in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds()]
['in'=>Mage::getModel('catalog/product_status')->getSaleableStatusIds()]
);
$collection->addFieldToFilter('type_id', $type);
$this->_walkCollection($collection, $store, [], $priceAttributeCodes);
Expand Down
8 changes: 3 additions & 5 deletions app/code/core/Mage/CatalogSearch/Model/Advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,10 @@ public function prepareProductCollection($collection)
->setStore(Mage::app()->getStore())
->addMinimalPrice()
->addTaxPercents()
->addStoreFilter()
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds()
]);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
->addStoreFilter();

Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
return $this;
}
}
7 changes: 3 additions & 4 deletions app/code/core/Mage/CatalogSearch/Model/Layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ public function prepareProductCollection($collection)
->addPriceData()
->addTaxPercents()
->addStoreFilter()
->addUrlRewrite()
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds()
]);
->addUrlRewrite();

Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);

return $this;
Expand Down
4 changes: 1 addition & 3 deletions app/code/core/Mage/Checkout/Block/Cart/Crosssell.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,10 @@ protected function _getCollection()
->getProductCollection()
->setStoreId(Mage::app()->getStore()->getId())
->addStoreFilter()
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds()
])
->setPageSize($this->_maxItemCount);
$this->_addProductAttributesAndPrices($collection);

Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);

Expand Down
4 changes: 1 addition & 3 deletions app/code/core/Mage/Tag/Block/Product/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,10 @@ protected function _getProductCollection()
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addTagFilter($this->getTag()->getId())
->addStoreFilter(Mage::app()->getStore()->getId())
->addAttributeToFilter('status', [
'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds()
])
->addMinimalPrice()
->addUrlRewrite()
->setActiveFilter();
Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_productCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection(
$this->_productCollection
);
Expand Down

0 comments on commit ab64ebe

Please sign in to comment.