Desired result:
On the order success page I want to show products that are related to the ones purchased by the user.
What I did so far:
- product attribute that contains related products
- added
echo $this->getChildHtml('related_products_list');
incheckout/success.phtml
- block that extends the product_list, and sets the appropriate collection (note: this is not a rewrite)
class Namespace_CustomersBought_Block_Product_List extends Mage_Catalog_Block_Product_List {
protected function _construct() {
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
// some more code to get the products I need in $relatedProducts
$this->setCollection($relatedProducts);
}
}
added in my
custom.xml
the following (paths are correct):<checkout_onepage_success> <reference name="content"> <block type="namespace_customersbought/product_list" name="related_products_list" template="module/product/related_list.phtml" after="-"> </block> </reference> </checkout_onepage_success>
Where it stopped working
It renders the div I added in checkout/success.phtml
, but the getChildHtml()
call is empty.
Also, I use Magneto Debug
- and the layout update contains my XML.
What I need help with
I would like to understand why this is not working. If I replace <checkout_onepage_success>
with <cms_index_index>
I get the desired block on the homepage (without having getChildHtml()
), so why do they have different behavior?
Also - ideally I wouldn't need to modify the checkout/success.phtml
file, it should be output automatically.
I know I'm missing something very simple, but I can't figure out what.
Thank you.