Skip to content

Commit 457591f

Browse files
authored
Respect Display Out of Stock Products setting for linked products (#584)
1 parent 100705e commit 457591f

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

app/code/core/Mage/Catalog/Block/Product/List/Crosssell.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ protected function _prepareData()
4343

4444
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
4545

46+
if (!Mage::helper('cataloginventory')->isShowOutOfStock()) {
47+
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($this->_itemCollection);
48+
}
49+
4650
$this->_itemCollection->load();
4751

4852
foreach ($this->_itemCollection as $product) {

app/code/core/Mage/Catalog/Block/Product/List/Related.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ protected function _prepareData()
4444
}
4545
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
4646

47+
if (!Mage::helper('cataloginventory')->isShowOutOfStock()) {
48+
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($this->_itemCollection);
49+
}
50+
4751
$this->_itemCollection->load();
4852

4953
foreach ($this->_itemCollection as $product) {

app/code/core/Mage/Catalog/Block/Product/List/Upsell.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ protected function _prepareData()
4848
}
4949
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
5050

51+
if (!Mage::helper('cataloginventory')->isShowOutOfStock()) {
52+
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($this->_itemCollection);
53+
}
54+
5155
if ($this->getItemLimit('upsell') > 0) {
5256
$this->_itemCollection->setPageSize($this->getItemLimit('upsell'));
5357
}

app/code/core/Mage/Checkout/Block/Cart/Crosssell.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ protected function _getCollection()
155155
$this->_addProductAttributesAndPrices($collection);
156156

157157
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
158+
// Always filter out-of-stock regardless of setting, since cart crosssell items are meant for immediate purchase
158159
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
159160

160161
return $collection;

0 commit comments

Comments
 (0)