1

Normally the build in functionality goes just for a single product view as it has no i.e. setProduct() method. I already modded the module so every product can be set from category list/grid template which works as expected. As you shouldn't build your blocks hardcoded inside the template I want to move from a

Mage::getSingleton('core/layout')->createBlock('productalert/product_view')->setTemplate('productalert/product/view.phtml')

to a simple

$this->getChild('productalert_price')

call and have the rest inside the layout.xml of the pricealert module. Sadly every handle etc. won't achieve the expected result.

For now I have:

<default>
        <reference name="content">
            <reference name="product_list">
                <block type="productalert/product_view" name="productalert_price" template="productalert/product/view.phtml">
                    <action method="setHtmlClass">
                        <value>alert-price link-price-alert</value>
                    </action>
                    <action method="setSignupLabel" translate="value">
                        <value>Sign up for price alert</value>
                    </action>
                </block>
            </reference>
        </reference>
    </default>

  • Try adding as="productalert_price" on the block productalert/product_view – Marius Jan 5 '15 at 14:35
2

it so simple and please add this code which is give product alert

$type='stock'; // type is stock/price
$this->getUrl('productalert/add/' . $type, array(
            'product_id'    => $_product()->getId(),
            Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => Mage::helper('core')->getEncodedUrl()
        ));
  • That isn't the problem (calling the productalert block directly already works as a charm) but not being able to add the block directly to all product list/grid views via layout.xml. thanks anyway – Pascal Heidmann Jan 5 '15 at 14:49
1

As you might already figured out: Your problem is, you need a bunch of blocks, not a single one. Because you need for every product your own block.

  1. So you either achieve this, by setting the product in the registry (this might be done already by magento, please check) and then just use the product from the registry

  2. or you create a block for every product, as you already do.

Make sure if you use 1. that you don't save any product specific states in the block!

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.