You have to customize the core file by copying it in the local/Mage directory.
Suppose that you have to variations size & color.
Open the file app\code\core\Mage\Catalog\Model\Layer.php
After the following code:-
$collection
->addAttributeToSelect(
Mage::getSingleton('catalog/config')->getProductAttributes()
)
->addMinimalPrice()
->addFinalPrice()
->addTaxPercents()
->addUrlRewrite($this->getCurrentCategory()->getId());
You have to customize it for the selected attribute:-
For example :-
if(isset($_GET['size']))
{
$query = 'SELECT value FROM aw_layerednavigation_filter_option_eav WHERE name="title" AND option_id IN ( '.$_GET['size'].' )';
$results = $readConnection->fetchAll($query);
$sizeLabels = array();
foreach($results as $_r){
$size_labels[] = $_r['value'];
}
$query = 'SELECT parent_id FROM advance_filter WHERE size IN ( '.implode(",",$size_labels).' ) AND qty > 0';
$results = $readConnection->fetchAll($query);
foreach($results as $_r){
$size_prod_Ids[] = $_r['parent_id'];
}
}
$color_prod_Ids = array();
if(isset($_GET['color']))
{
$query = 'SELECT value FROM aw_layerednavigation_filter_option_eav WHERE name="title" AND option_id IN ( '.$_GET['color'].' )';
$results = $readConnection->fetchAll($query);
$color_labels = array();
foreach($results as $_r){
$color_labels[] = strtoupper($_r['value']);
}
$query = 'SELECT parent_id FROM advance_filter WHERE color IN ( "'.implode(",",$color_labels).'" ) AND qty > 0';
$results = $readConnection->fetchAll($query);
foreach($results as $_r){
$color_prod_Ids[] = $_r['parent_id'];
}
}
$productIds = array_merge($size_prod_Ids,$color_prod_Ids);
if(count($productIds) > 0){
$collection->addAttributeToFilter('entity_id', array('in' => array_unique($productIds)));
}
hope this will help..!!
app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Attribute.php::getCount
the layered navigation links being retrieved uses the index tables, which don't include the products that aren't visible individually. So you would have to add a few additional queries to get the associated simple products and check if the combination of two (or more) attributes exists. This is where the performance would get killed, especially if you have a lot of attributes / values. – obsirdiancatalog_product_entity, catalog_product_index_eav
If you take a look at yours, you'll see the data just isn't there. Maybe if you ask a sql wizard how you could join those tables with the relevant data. Add this before the return statement ingetCount()
to log the query:Mage::log((string) $select);
– obsirdian