0

i'm working on an heavy customised magento site and there is a catalog/product/view/list.phtml which shows 2 product categories on the same page. The combination of the 2 products should create a bundle product but adding it to the cart doesn't work as it options are not stored properly in the database. I believe I need to add those 2 blocks

bundle/catalog/product/view/type/bundle.phtml

and

bundle/catalog/product/view/type/bundle/options.phtml

to generate the Json array with all options. I'm not able to load them because I'm working on the category_view block, while I need the product_view block so $this->getJsonConfig() will work. Tried to include

<block type="bundle/catalog_product_view_type_bundle" name="product.info.bundle" as="product_type_data" template="bundle/catalog/product/view/type/bundle.phtml">

but as soon as I insert it I got a fatal error.

Can anyone help, please? thank you very much

1 Answer 1

1

The error you're getting is for sure caused by the fact that you have no product in the registry. The Mage_Bundle_Block_Catalog_Product_View_Type_Bundle block extends Mage_Catalog_Block_Product_View_Abstract which loads the product from the registry. The value in the registry on the other hand is set in the product controller, view action. Therefor loading that block on the category page will never work.

However, you can override the category block and add the missing method inside, and adapt it. Write your own module, extend Mage_Catalog_Block_Product_View and add 2 methods: getJsonConfig and getOptions (both from the bundle view). The only difference is that you will need to pass the product as an argument, and don't load it using the $this->getProduct() method. Something like this:

foreach($productCollection as $product):
    $jsonConfig = $this->getJsonConfig($product);
endforeach;

I can't guarantee that this is the best solution to achieve your goal, but it's a starting point. The downside is that these methods seem to a lot of loads from the database, therefor it will slow the page.

1
  • thank you, will give a shot, it should not slow down the page as in that particular category view i will select only 1 bundle product.
    – apedic
    May 10, 2016 at 15:36

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.