0

I have a strange problem, which gives me the feeling i missed some concept:

In an observer triggered via event dispatch <catalog_product_collection_load_before> i fetch the collection and do a join:

        $select->joinLeft(
            array('partner_stock' => Mage::getSingleton('core/resource')->getTableName('xxx_partner_stock')),
            "`e`.`sku`=`partner_stock`.`sku` AND `partner_stock`.`customer_id`={$partnerId}",
            array('stock_id'=>'stock_id')
        );

In a later observer listening to <catalog_product_collection_load_after> i fetch the select and its missing the join. Any clou why?

3
  • Have you actually inspected the select object to confirm the join is missing? Commented Oct 21, 2014 at 16:54
  • of course i did a $collection->getSelect()->__toString() in the load before and load after observer. Its there before, but its gone in the after observer. Commented Oct 21, 2014 at 17:16
  • It could be that some other code is calling reset() against the select object, have you looked for that? Commented Oct 21, 2014 at 17:18

1 Answer 1

4

Take a look at the catalog_block_product_list_collection observer used in Mage_Review (review/observer::catalogBlockProductCollectionBeforeToHtml). Within this observer method, Magento loads the collection ($productCollection->load()). Better to use this event to do what you want: catalog_product_collection_apply_limitations_after.

Order of events:

  1. catalog_block_product_list_collection (used by review module, after collection is loaded its not editable anymore)
  2. catalog_product_collection_load_before
  3. catalog_product_collection_load_after
1
  • perfect. it was the review observer! Commented Oct 22, 2014 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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