3

In my project, what I did is copied all the layouts and template files of base/default to my new theme folder default/efk.

After that, I made many changes in some layout and template files as needed.

My project is somewhat different from the default magento. In my project, I have configurable products in which each consists of 3 types of simple products.

Now, if any of the single simple product is out of stock, then I need to show "Sign up to get notified when this product is back in stock" as shown in default magento.

When I did some research I figured it out that this link is coming from the phtml line

<?php echo $this->getChildHtml('alert_urls') ?>

I added the same line in my project in template/catalog/product/view.phtml, but I can't see the "Sign up to get notified when this product is back in stock".

PS: The reference of the block "alert_urls" are not changed. They are same as they are in default magento but in my theme folder instead.

EDIT:

The flow as I understand magento is as follows:

layout/catalog.xml (the block location)

    <catalog_product_view translate="label">
        <reference name="content">
            <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
                <block type="core/text_list" name="alert.urls" as="alert_urls" translate="label">
                <label>Alert Urls</label>
                </block>

         //some other blocks

layout/productalert.xml (the block reference location)

<layout version="0.1.0">
    <catalog_product_view>
        <reference name="content">
            <reference name="product.info">
                <reference name="alert.urls">
                    <block type="productalert/product_view" name="productalert.price" as="productalert_price" template="productalert/product/view.phtml">
                        <action method="preparePriceAlertData"/>
                        <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>
                    <block type="productalert/product_view" name="productalert.stock" as="productalert_stock" template="productalert/product/view.phtml">
                        <action method="prepareStockAlertData"/>
                        <action method="setHtmlClass"><value>alert-stock link-stock-alert</value></action>
                        <action method="setSignupLabel" translate="value"><value>Sign up to get notified when this product is back in stock</value></action>
                    </block>
                </reference>
            </reference>
        </reference>
    </catalog_product_view>
</layout>

productalert/product/view.phtml (the block's template -- Stock)

<?php /* @var $this Mage_ProductAlert_Block_Product_View */?>
<h1>Hello</h1>
<p class="<?php echo $this->getHtmlClass() ?>">
    <a href="<?php echo $this->escapeHtml($this->getSignupUrl()) ?>" title="<?php echo $this->escapeHtml($this->__($this->getSignupLabel())); ?>"><?php echo $this->escapeHtml($this->__($this->getSignupLabel())); ?></a>
</p>

Here is the screenshot:

enter image description here

0

Please ensure system configuration from admin in enable

System > Configuration > Catalog > Allow Alert When Product Comes Back in Stock - Yes
0

If you still have this issue, even if you ENABLED the option Allow Alert When Product Comes Back in Stock from the admin panel and everything is right with your template and layout files, then check the block Mage_ProductAlert_Block_Product_View and the method prepareStockAlertData() whether if it get's inside the following if block.

if (!Mage::getStoreConfigFlag(Mage_ProductAlert_Model_Observer::XML_PATH_STOCK_ALLOW)
            || !$this->_product || $this->_product->isAvailable()
        ) {
            $this->setTemplate('');
            return;
        }

If its get inside this then either the product is still in stock and available for purchase (in case of back orders) or no product instance or you might not have enabled this in the admin panel. Either of these three might be the reason its not showing up in your product page !

Hope this helps !

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.