-
- Nadya

-
Total Posts: 11
Joined: 2009-03-10
Kiev, Ukraine
|
Thank you Colin for your code. It really helped me.
But It does not decide problem with Layered Navigation.
there are count of products with ‘in stock’ and ‘out of stock’.
I decided it by adding condition in SQL query in file app/code/core/Mage/CatalogIndex/Model/Mysql4/Attribute.php (str 71)
public function getCount($attribute, $entitySelect) { ... $select->from('', $fields) ->join(array('index'=>$this->getMainTable()), 'index.entity_id=e.entity_id', array()) ->where('index.store_id = ?', $this->getStoreId()) ->where('index.attribute_id = ?', $attribute->getId()) ->group('index.value'); // this join was added for count in layered navigation products only 'in stock' status $select->join(array('stock'=>'cataloginventory_stock_status'), 'stock.product_id=e.entity_id AND stock_status=1', array());
$select = $select->__toString(); ...
and the same one for price filtering app/code/core/Mage/CatalogIndex/Model/Mysql4/Price.php (str. 130)
public function getCount($range, $attribute, $entitySelect) { ... $select->from('', $fields) ->group('range') ->where('price_table.website_id = ?', $this->getWebsiteId()) ->where('price_table.attribute_id = ?', $attribute->getId());
// this join was added for count in layered navigation products only 'in stock' status $select->join(array('stock'=>'cataloginventory_stock_status'), 'stock.product_id=e.entity_id AND stock_status=1', array()); $result = $this->_getReadAdapter()->fetchAll($select); ...
of course better to do this changes in additional module (in app/code/local/...) not in Mage (app/code/core/Mage)
if somebody knows better way, please share
|