Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Product Alert - Notify HTML in Product List view
 
tselaty
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2009-05-18
 

After scouring around Magento\’s code, I was unable to locate or find how add the same functionality from the:

Product View template

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

to work in the Product List template.

Does anybody know how to do this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tselaty
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2009-05-18
 

Answered my own question:

Edit:

/app/code/core/Mage/ProductAlert/Helper/Data.php

public function getSaveUrl($type)
    
{
        
return $this->_getUrl('productalert/add/' $type, array(
            
'product_id'    => $this->getProduct()->getId(),
            
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
        ));
    
}

To

public function getSaveUrl($type$product=null)
    
{
        
if(!empty($product)) {
            $product_id 
$product->getId();
        
else {
            $this
->getProduct()->getId();
        
}
        
        
return $this->_getUrl('productalert/add/' $type, array(
            
'product_id'    => $product,
            
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
        ));
    
}

In

/app/design/frontend/default/{your_theme}/template/catalog/product/list.phtml

Add the following code wherever you like (preferably under the Out of stock message).

<a href="<?php echo Mage::helper('productalert')->getSaveUrl('stock', $_product); ?>">&nbsp;Notify Me When Available</a>
 
Magento Community Magento Community
Magento Community
Magento Community
 
georgesmith1
Jr. Member
 
Total Posts:  5
Joined:  2011-02-25
 

Thanks for this issue, I am just still for look that when i am finding more about this than i am post this for you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
klipach
Jr. Member
 
Total Posts:  4
Joined:  2009-06-21
 

There is an error in tselaty‘s post in file /app/code/core/Mage/ProductAlert/Helper/Data.php, here is right source:

/app/code/core/Mage/ProductAlert/Helper/Data.php

public function getSaveUrl($type)
    
{
        
return $this->_getUrl('productalert/add/' $type, array(
            
'product_id'    => $this->getProduct()->getId(),
            
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
        ));
    
}

To

public function getSaveUrl($type$product=null)
    
{
        
if(!empty($product)) {
            $product_id 
$product->getId();
        
else {
            $product_id 
$this->getProduct()->getId();
        
}
        
        
return $this->_getUrl('productalert/add/' $type, array(
            
'product_id'    => $product_id,
            
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
        ));
}

In

/app/design/frontend/default/{your_theme}/template/catalog/product/list.phtml

Add the following code wherever you like (preferably under the Out of stock message).

<a href="<?php echo Mage::helper('productalert')->getSaveUrl('stock', $_product); ?>">&nbsp;Notify Me When Available</a>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Will Josefi Gazin
Jr. Member
 
Total Posts:  4
Joined:  2009-10-05
 

I have put the code in app/code/local/Mage/ProductAlert/Helper/Data.php for don’t touch in core code

worked very well

below is the code

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Mage
 * @package     Mage_ProductAlert
 * @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */


/**
 * ProductAlert data helper
 *
 * @category   Mage
 * @package    Mage_ProductAlert
 * @author      Magento Core Team <core@magentocommerce.com>
 */
class Mage_ProductAlert_Helper_Data extends Mage_Core_Helper_Url {
    
public function getSaveUrl($type$product=null{
        
if(!empty($product)) {
            $product_id 
$product->getId();
        
else {
            $product_id 
$this->getProduct()->getId();
        
}

        
return $this->_getUrl('productalert/add/' $type, array('product_id'    => $product_idMage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()));
    
}
}

Thanks everyone :)

 
Magento Community Magento Community
Magento Community
Magento Community
 
marciomaciel
Jr. Member
 
Avatar
Total Posts:  28
Joined:  2009-06-01
Brazil
 

Hi!

Not need to change ProductAlert Helper. This is the best way without change any code:

<?php
if (!$_product->isSaleable()) 
{
   $productAlertHelper 
$this->helper('productalert')->setProduct($_product); 
}
?>
<a href="<?php echo Mage::helper('productalert')->getSaveUrl('stock', $_product); ?>"> Notify Me When Available</a>

wink

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top