From ecf461141096d20c9ff29b294fa0a562a737621d Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Thu, 15 Sep 2022 14:49:31 +0100 Subject: [PATCH 1/5] Fixed Mage_Catalog_Model_Product_Status::addSaleableFilterToCollection() does nothing --- .../Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php | 5 ++--- .../Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php | 5 ++--- .../core/Mage/Bundle/Block/Catalog/Product/List/Partof.php | 3 +-- app/code/core/Mage/Checkout/Block/Cart/Crosssell.php | 2 +- app/code/core/Mage/Tag/Block/Product/Result.php | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php index 3e7066c3185..4f8592dd322 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php @@ -103,13 +103,12 @@ 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() )) - ->addAttributeToSelect('gift_message_available'); - - Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection); + ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); $this->setCollection($collection); return parent::_prepareCollection(); diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php index 72a1da32c5a..ed120bb3831 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php @@ -68,7 +68,8 @@ protected function _prepareCollection() ->addAttributeToSelect('attribute_set_id') ->addAttributeToFilter('type_id', ['in' => $this->getAllowedSelectionTypes()]) ->addFilterByRequiredOptions() - ->addStoreFilter(); + ->addStoreFilter() + ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); if ($products = $this->_getProducts()) { $collection->addIdFilter($this->_getProducts(), true); @@ -79,8 +80,6 @@ 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(); diff --git a/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php b/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php index 28c3778950c..2deefa182ce 100644 --- a/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php +++ b/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php @@ -41,8 +41,8 @@ protected function _prepareData() ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) ->addAttributeToSort('position', 'asc') ->addStoreFilter() + ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED) ->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()); @@ -52,7 +52,6 @@ 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'); diff --git a/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php b/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php index e77fae9d7ab..4d1047dbefe 100644 --- a/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php +++ b/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php @@ -165,10 +165,10 @@ protected function _getCollection() ->getProductCollection() ->setStoreId(Mage::app()->getStore()->getId()) ->addStoreFilter() + ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED) ->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); diff --git a/app/code/core/Mage/Tag/Block/Product/Result.php b/app/code/core/Mage/Tag/Block/Product/Result.php index d1a0d8c9202..c4dc6d6f027 100644 --- a/app/code/core/Mage/Tag/Block/Product/Result.php +++ b/app/code/core/Mage/Tag/Block/Product/Result.php @@ -98,10 +98,10 @@ protected function _getProductCollection() ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) ->addTagFilter($this->getTag()->getId()) ->addStoreFilter(Mage::app()->getStore()->getId()) + ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED) ->addMinimalPrice() ->addUrlRewrite() ->setActiveFilter(); - Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_productCollection); Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection( $this->_productCollection ); From a5a2f73e15a6a2cd76a28a129385b32159b1eb20 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 16 Sep 2022 10:31:50 +0200 Subject: [PATCH 2/5] Fixed Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection() that does nothing --- .../Mage/Adminhtml/Model/Sales/Order/Random.php | 8 ++++---- .../Mage/Catalog/Block/Seo/Sitemap/Product.php | 14 ++++++-------- app/code/core/Mage/Catalog/Model/Layer.php | 5 ++--- .../core/Mage/CatalogSearch/Model/Advanced.php | 6 +++--- app/code/core/Mage/CatalogSearch/Model/Layer.php | 5 ++--- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php index 71a1e6c367b..6e8fccf8c05 100644 --- a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php +++ b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php @@ -76,13 +76,13 @@ protected function _getCustomers() protected function _getProducts() { if (!$this->_productCollection) { - $this->_productCollection= Mage::getResourceModel('catalog/product_collection'); - //$this->_productCollection->getEntity()->setStore($this->_getStore()); - Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_productCollection); + $this->_productCollection = Mage::getResourceModel('catalog/product_collection'); 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', Mage_Catalog_Model_Product_Status::STATUS_ENABLED) ->load(); } return $this->_productCollection->getItems(); diff --git a/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php b/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php index 027d647ac93..ff6aebfa5bc 100644 --- a/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php +++ b/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php @@ -36,18 +36,16 @@ class Mage_Catalog_Block_Seo_Sitemap_Product extends Mage_Catalog_Block_Seo_Site */ protected function _prepareLayout() { - $collection = Mage::getModel('catalog/product')->getCollection(); /** @var Mage_Catalog_Model_Resource_Product_Collection $collection */ - - $collection->addAttributeToSelect('name'); - $collection->addAttributeToSelect('url_key'); - $collection->addStoreFilter(); - - Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); + $collection = Mage::getModel('catalog/product')->getCollection(); + $collection + ->addAttributeToSelect('name') + ->addAttributeToSelect('url_key') + ->addStoreFilter() + ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); $this->setCollection($collection); - return $this; } diff --git a/app/code/core/Mage/Catalog/Model/Layer.php b/app/code/core/Mage/Catalog/Model/Layer.php index 74cfb289b0f..f8275de05ed 100644 --- a/app/code/core/Mage/Catalog/Model/Layer.php +++ b/app/code/core/Mage/Catalog/Model/Layer.php @@ -114,9 +114,8 @@ public function prepareProductCollection($collection) ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) ->addPriceData() ->addTaxPercents() - ->addUrlRewrite($this->getCurrentCategory()->getId()); - - Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); + ->addUrlRewrite($this->getCurrentCategory()->getId()) + ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $this; diff --git a/app/code/core/Mage/CatalogSearch/Model/Advanced.php b/app/code/core/Mage/CatalogSearch/Model/Advanced.php index 7d57c6b3954..113bdc60d69 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Advanced.php +++ b/app/code/core/Mage/CatalogSearch/Model/Advanced.php @@ -327,10 +327,10 @@ public function prepareProductCollection($collection) ->setStore(Mage::app()->getStore()) ->addMinimalPrice() ->addTaxPercents() - ->addStoreFilter(); - - Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); + ->addStoreFilter() + ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); + return $this; } } diff --git a/app/code/core/Mage/CatalogSearch/Model/Layer.php b/app/code/core/Mage/CatalogSearch/Model/Layer.php index 99ffd3e4686..ff8404e33c2 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Layer.php +++ b/app/code/core/Mage/CatalogSearch/Model/Layer.php @@ -59,9 +59,8 @@ public function prepareProductCollection($collection) ->addPriceData() ->addTaxPercents() ->addStoreFilter() - ->addUrlRewrite(); - - Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); + ->addUrlRewrite() + ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); return $this; From 3732513c165f769b5eb3148c5884814b9e972c4e Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sun, 9 Oct 2022 20:44:46 +0100 Subject: [PATCH 3/5] Converted to getSaleableStatusIds() and getVisibleStatusIds() --- .../Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php | 4 +++- app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php | 4 +++- .../Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php | 4 +++- .../core/Mage/Bundle/Block/Catalog/Product/List/Partof.php | 4 +++- app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php | 4 +++- app/code/core/Mage/Catalog/Model/Layer.php | 4 +++- app/code/core/Mage/CatalogSearch/Model/Advanced.php | 4 +++- app/code/core/Mage/CatalogSearch/Model/Layer.php | 4 +++- app/code/core/Mage/Checkout/Block/Cart/Crosssell.php | 4 +++- app/code/core/Mage/Tag/Block/Product/Result.php | 4 +++- 10 files changed, 30 insertions(+), 10 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php index 4f8592dd322..b5c4f053259 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php @@ -108,7 +108,9 @@ protected function _prepareCollection() ->addAttributeToFilter('type_id', array_keys( Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray() )) - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('catalog/product_status')->getSaleableStatusIds() + ]); $this->setCollection($collection); return parent::_prepareCollection(); diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php index 6e8fccf8c05..3a6c165a06b 100644 --- a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php +++ b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php @@ -82,7 +82,9 @@ protected function _getProducts() ->addAttributeToSelect('name') ->addAttributeToSelect('sku') ->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED) + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + ]) ->load(); } return $this->_productCollection->getItems(); diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php index ed120bb3831..bf2a6dfc6a8 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php @@ -69,7 +69,9 @@ protected function _prepareCollection() ->addAttributeToFilter('type_id', ['in' => $this->getAllowedSelectionTypes()]) ->addFilterByRequiredOptions() ->addStoreFilter() - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('catalog/product_status')->getSaleableStatusIds() + ]); if ($products = $this->_getProducts()) { $collection->addIdFilter($this->_getProducts(), true); diff --git a/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php b/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php index 2deefa182ce..813e8d6c8bb 100644 --- a/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php +++ b/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php @@ -41,7 +41,9 @@ protected function _prepareData() ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) ->addAttributeToSort('position', 'asc') ->addStoreFilter() - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED) + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('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()); diff --git a/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php b/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php index ff6aebfa5bc..79ae54fb017 100644 --- a/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php +++ b/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php @@ -42,7 +42,9 @@ protected function _prepareLayout() ->addAttributeToSelect('name') ->addAttributeToSelect('url_key') ->addStoreFilter() - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + ]); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); $this->setCollection($collection); diff --git a/app/code/core/Mage/Catalog/Model/Layer.php b/app/code/core/Mage/Catalog/Model/Layer.php index f8275de05ed..cdd2883cfb7 100644 --- a/app/code/core/Mage/Catalog/Model/Layer.php +++ b/app/code/core/Mage/Catalog/Model/Layer.php @@ -115,7 +115,9 @@ public function prepareProductCollection($collection) ->addPriceData() ->addTaxPercents() ->addUrlRewrite($this->getCurrentCategory()->getId()) - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + ]); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $this; diff --git a/app/code/core/Mage/CatalogSearch/Model/Advanced.php b/app/code/core/Mage/CatalogSearch/Model/Advanced.php index 113bdc60d69..9f72a25aeeb 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Advanced.php +++ b/app/code/core/Mage/CatalogSearch/Model/Advanced.php @@ -328,7 +328,9 @@ public function prepareProductCollection($collection) ->addMinimalPrice() ->addTaxPercents() ->addStoreFilter() - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + ]); Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); return $this; diff --git a/app/code/core/Mage/CatalogSearch/Model/Layer.php b/app/code/core/Mage/CatalogSearch/Model/Layer.php index ff8404e33c2..4028a5b1913 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Layer.php +++ b/app/code/core/Mage/CatalogSearch/Model/Layer.php @@ -60,7 +60,9 @@ public function prepareProductCollection($collection) ->addTaxPercents() ->addStoreFilter() ->addUrlRewrite() - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + ]); Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); return $this; diff --git a/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php b/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php index 4d1047dbefe..8a35e290471 100644 --- a/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php +++ b/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php @@ -165,7 +165,9 @@ protected function _getCollection() ->getProductCollection() ->setStoreId(Mage::app()->getStore()->getId()) ->addStoreFilter() - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED) + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('catalog/product_status')->getSaleableStatusIds() + ]) ->setPageSize($this->_maxItemCount); $this->_addProductAttributesAndPrices($collection); diff --git a/app/code/core/Mage/Tag/Block/Product/Result.php b/app/code/core/Mage/Tag/Block/Product/Result.php index c4dc6d6f027..a3fef4cc09d 100644 --- a/app/code/core/Mage/Tag/Block/Product/Result.php +++ b/app/code/core/Mage/Tag/Block/Product/Result.php @@ -98,7 +98,9 @@ protected function _getProductCollection() ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) ->addTagFilter($this->getTag()->getId()) ->addStoreFilter(Mage::app()->getStore()->getId()) - ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED) + ->addAttributeToFilter('status', [ + 'in' => Mage::getModel('catalog/product_status')->getSaleableStatusIds() + ]) ->addMinimalPrice() ->addUrlRewrite() ->setActiveFilter(); From 96cd5990fa611cfb19befc43b0847f64430af8ab Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Thu, 13 Oct 2022 10:18:13 +0100 Subject: [PATCH 4/5] Converted to getSingleton --- .../Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php | 2 +- .../Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php | 2 +- app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php | 2 +- app/code/core/Mage/CatalogIndex/Model/Indexer.php | 2 +- app/code/core/Mage/Checkout/Block/Cart/Crosssell.php | 2 +- app/code/core/Mage/Tag/Block/Product/Result.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php index 7f89ae17c8b..d41e35db099 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php @@ -110,7 +110,7 @@ protected function _prepareCollection() Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray() )) ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getSaleableStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds() ]); $this->setCollection($collection); diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php index 0fb2ad0f527..4084f22d847 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php @@ -71,7 +71,7 @@ protected function _prepareCollection() ->addFilterByRequiredOptions() ->addStoreFilter() ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getSaleableStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds() ]); if ($products = $this->_getProducts()) { diff --git a/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php b/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php index aa9aaf60fb6..1bf140dacb3 100644 --- a/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php +++ b/app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php @@ -43,7 +43,7 @@ protected function _prepareData() ->addAttributeToSort('position', 'asc') ->addStoreFilter() ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getSaleableStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds() ]) ->addMinimalPrice() ->joinTable('bundle/option', 'parent_id=entity_id', ['option_id' => 'option_id']) diff --git a/app/code/core/Mage/CatalogIndex/Model/Indexer.php b/app/code/core/Mage/CatalogIndex/Model/Indexer.php index 87190151474..41341d8f6e8 100644 --- a/app/code/core/Mage/CatalogIndex/Model/Indexer.php +++ b/app/code/core/Mage/CatalogIndex/Model/Indexer.php @@ -294,7 +294,7 @@ public function plainReindex($products = null, $attributes = null, $stores = nul $collection = $this->_getProductCollection($store, $products); $collection->addAttributeToFilter( 'status', - ['in'=>Mage::getModel('catalog/product_status')->getSaleableStatusIds()] + ['in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds()] ); $collection->addFieldToFilter('type_id', $type); $this->_walkCollection($collection, $store, [], $priceAttributeCodes); diff --git a/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php b/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php index ec0593b29c4..4daea3cc379 100644 --- a/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php +++ b/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php @@ -167,7 +167,7 @@ protected function _getCollection() ->setStoreId(Mage::app()->getStore()->getId()) ->addStoreFilter() ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getSaleableStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds() ]) ->setPageSize($this->_maxItemCount); $this->_addProductAttributesAndPrices($collection); diff --git a/app/code/core/Mage/Tag/Block/Product/Result.php b/app/code/core/Mage/Tag/Block/Product/Result.php index faecf3cd257..d13f015c4fb 100644 --- a/app/code/core/Mage/Tag/Block/Product/Result.php +++ b/app/code/core/Mage/Tag/Block/Product/Result.php @@ -100,7 +100,7 @@ protected function _getProductCollection() ->addTagFilter($this->getTag()->getId()) ->addStoreFilter(Mage::app()->getStore()->getId()) ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getSaleableStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds() ]) ->addMinimalPrice() ->addUrlRewrite() From 1a630063696b49ec2993d0535e268ee592214c6c Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Thu, 13 Oct 2022 10:20:05 +0100 Subject: [PATCH 5/5] Converted to getSingleton --- app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php | 2 +- app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php | 2 +- app/code/core/Mage/Catalog/Model/Layer.php | 2 +- app/code/core/Mage/CatalogSearch/Model/Advanced.php | 2 +- app/code/core/Mage/CatalogSearch/Model/Layer.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php index db11f55f3d1..707aa96688e 100644 --- a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php +++ b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php @@ -84,7 +84,7 @@ protected function _getProducts() ->addAttributeToSelect('sku') ->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds() ]) ->load(); } diff --git a/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php b/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php index 815d30df053..3310dfa5ad6 100644 --- a/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php +++ b/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php @@ -44,7 +44,7 @@ protected function _prepareLayout() ->addAttributeToSelect('url_key') ->addStoreFilter() ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds() ]); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); diff --git a/app/code/core/Mage/Catalog/Model/Layer.php b/app/code/core/Mage/Catalog/Model/Layer.php index 9db9c4d6ae4..940e7cfeed4 100644 --- a/app/code/core/Mage/Catalog/Model/Layer.php +++ b/app/code/core/Mage/Catalog/Model/Layer.php @@ -117,7 +117,7 @@ public function prepareProductCollection($collection) ->addTaxPercents() ->addUrlRewrite($this->getCurrentCategory()->getId()) ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds() ]); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); diff --git a/app/code/core/Mage/CatalogSearch/Model/Advanced.php b/app/code/core/Mage/CatalogSearch/Model/Advanced.php index 66421a52757..cf2a24b9cdc 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Advanced.php +++ b/app/code/core/Mage/CatalogSearch/Model/Advanced.php @@ -330,7 +330,7 @@ public function prepareProductCollection($collection) ->addTaxPercents() ->addStoreFilter() ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds() ]); Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); diff --git a/app/code/core/Mage/CatalogSearch/Model/Layer.php b/app/code/core/Mage/CatalogSearch/Model/Layer.php index d2f9ede6510..fef37c96505 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Layer.php +++ b/app/code/core/Mage/CatalogSearch/Model/Layer.php @@ -62,7 +62,7 @@ public function prepareProductCollection($collection) ->addStoreFilter() ->addUrlRewrite() ->addAttributeToFilter('status', [ - 'in' => Mage::getModel('catalog/product_status')->getVisibleStatusIds() + 'in' => Mage::getSingleton('catalog/product_status')->getVisibleStatusIds() ]); Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);