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?

  • Have you actually inspected the select object to confirm the join is missing? – Jonathan Hussey Oct 21 '14 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. – Michael Leiss Oct 21 '14 at 17:16
  • It could be that some other code is calling reset() against the select object, have you looked for that? – Jonathan Hussey Oct 21 '14 at 17:18
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
  • perfect. it was the review observer! – Michael Leiss Oct 22 '14 at 9:38

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.