8

Recently I was studying how the options of the layered navigation filter on the category page are determined and retrieved. I have dug a bit into the models and database for it, and there I found the following mechanism which I do not understand:

Situation: Say, I have an attribute named color (attribute_id = 133), a simple product A (entity_id = 26), and a bundled product B (entity_id = 27), and A is added to B as its bundle item, in Magento ver. 1.9.0.1.

Step 1: color is not set for both A and B

enter image description here

Step 2: color is set as Black (value_id = 19) for B

enter image description here

Step 3: color is set as White (value_id = 18) for A

enter image description here

From step 3, we could see that apparently attributes of the bundle items (A in this case) are also saved as if they are the attributes of the bundle product (B in this case) itself. And I believe that this is why the attributes of the bundle items of bundle products also appear in the layered navigation filter.

I would like to ask why is it designed this way? Why would the system save attributes of the children products to the parent product as well? How does it help in any specific process in the system?

Thanks in advance.

2

It is the same way with configurable products.

If you are looking for white shoes and the configurable products solves this problem for you, the product is offered. I think it is easy as this. So if your searched product is part of a bundle product, this product is offered too.

| improve this answer | |
  • Thanks for your reply. I understand your points, but I am curious why it has to be achieved this way? 'Cause it seems to me that it kind of lowers the flexibility when someone would not want the attributes of the children products to be hooked up with the parent product (or they simply do not want attributes of children products to show up in the filter). And I am not sure what purposes this "mechanism" serve, other than preparing data for the filter. So I am not sure if I could remove this step safely without tampering other parts of the system. – d.yuk Jan 25 '15 at 6:43
  • You don't. Remove it and then test. I think it is no problem. In the past I only added information, never removed some. But still: try and test :-) Good luck! – Fabian Blechschmidt Jan 25 '15 at 8:10
  • 1
    Yeah, I think you're right. In the end I figured out those "links" are actually created during product attributes re-indexing. So I guess those relations are created for faster searching and filtering purposes, and it should be fine to remove them. Thanks again. – d.yuk Jan 26 '15 at 14:51
  • @d.yuk I'm trying to achieve the same thing. Could you post how you achieved this with the indexer? – Aaron Pollock Jul 8 '16 at 12:45
  • 1
    @AaronPollock I have edited the question and put the method there. Hope it could help. Good luck! – d.yuk Jul 11 '16 at 5:56
7

Update: how to stop the indexer from including child products

  1. Extend and modify Mage_Catalog_Model_Resource_Product_Indexer_Eav_Abstract.
  2. Look for the function _prepareRelationIndex().
  3. Modify the SQL query builder statement as follows:

Code:

$select = $write->select()
    ->from(array('l' => $this->getTable('catalog/product_relation')), 'parent_id')
    ->join(
        array('cs' => $this->getTable('core/store')),
        '',
        array())
    ->join(
        array('i' => $idxTable),
        'l.child_id = i.entity_id AND cs.store_id = i.store_id',
        array('attribute_id', 'store_id', 'value'))
    ->join(
        array('e' => 'catalog_product_entity'),
        'l.parent_id = e.entity_id',
        array())
    ->group(array(
        'l.parent_id', 'i.attribute_id', 'i.store_id', 'i.value'
    ))
    ->where('e.type_id != ?', 'bundle');

how to stop the indexer from including child products reference: addition of codes highlighted in red

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.