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 d41e35db099..c1ea269539f 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 @@ -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(); 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 707aa96688e..85770b8bab9 100644 --- a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php +++ b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php @@ -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(); 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 4084f22d847..29fed0029b0 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,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); @@ -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(); 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 1bf140dacb3..48d81e53892 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 @@ -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()); @@ -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'); 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 3310dfa5ad6..4b8000af435 100644 --- a/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php +++ b/app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php @@ -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; } diff --git a/app/code/core/Mage/Catalog/Model/Layer.php b/app/code/core/Mage/Catalog/Model/Layer.php index 940e7cfeed4..0dc5fa69d7b 100644 --- a/app/code/core/Mage/Catalog/Model/Layer.php +++ b/app/code/core/Mage/Catalog/Model/Layer.php @@ -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; diff --git a/app/code/core/Mage/CatalogIndex/Model/Indexer.php b/app/code/core/Mage/CatalogIndex/Model/Indexer.php index 41341d8f6e8..87190151474 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::getSingleton('catalog/product_status')->getSaleableStatusIds()] + ['in'=>Mage::getModel('catalog/product_status')->getSaleableStatusIds()] ); $collection->addFieldToFilter('type_id', $type); $this->_walkCollection($collection, $store, [], $priceAttributeCodes); diff --git a/app/code/core/Mage/CatalogSearch/Model/Advanced.php b/app/code/core/Mage/CatalogSearch/Model/Advanced.php index 1969757f417..e297c41c870 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Advanced.php +++ b/app/code/core/Mage/CatalogSearch/Model/Advanced.php @@ -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; } } diff --git a/app/code/core/Mage/CatalogSearch/Model/Layer.php b/app/code/core/Mage/CatalogSearch/Model/Layer.php index fef37c96505..4f741896951 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Layer.php +++ b/app/code/core/Mage/CatalogSearch/Model/Layer.php @@ -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; diff --git a/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php b/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php index 4daea3cc379..a39c0848f8a 100644 --- a/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php +++ b/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php @@ -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); diff --git a/app/code/core/Mage/Tag/Block/Product/Result.php b/app/code/core/Mage/Tag/Block/Product/Result.php index d13f015c4fb..3c0d0b4f540 100644 --- a/app/code/core/Mage/Tag/Block/Product/Result.php +++ b/app/code/core/Mage/Tag/Block/Product/Result.php @@ -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 );