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

getBlock(’customer_newsletter’) returns false
 
bcelenza
Member
 
Avatar
Total Posts:  44
Joined:  2008-08-27
 

Hey all,

I’ve recently noticed that the customer newsletter management page fails to load. No error, but upon inspection of the core code, I noticed that the code on line 57 of Newsletter/controllers/ManageController.php (if ($block = $this->getLayout()->getBlock(’customer_newsletter’)) {) is now returning false.

Any idea what could be causing this? I’m looking through the revision history and nothing appears to have been changed in this, the block, or the layout xml file.

Thanks in advance.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bcelenza
Member
 
Avatar
Total Posts:  44
Joined:  2008-08-27
 

Some more info:

On version 1.1.6 of magento. This failed to load the customer_newsletter block in all templates.

layout/newsletter.xml:

<newsletter_manage_index>
        <
update handle="customer_account"/>
        <
reference name="content">
            <
block type="customer/newsletter" name="customer_newsletter"/>
        </
reference>
    </
newsletter_manage_index>

ManageController.php:

class Mage_Newsletter_ManageController extends Mage_Core_Controller_Front_Action
{
    
/**
     * Action predispatch
     *
     * Check customer authentication for some actions
     */
    
public function preDispatch()
    
{
        parent
::preDispatch();
        if (!
Mage::getSingleton('customer/session')->authenticate($this)) {
            $this
->setFlag('''no-dispatch'true);
        
}
    }

    
public function indexAction()
    
{
             $this
->loadLayout();
            
$this->_initLayoutMessages('customer/session');
            
$this->_initLayoutMessages('catalog/session');

        if (
$block $this->getLayout()->getBlock('customer_newsletter')) {
            $block
->setRefererUrl($this->_getRefererUrl());
        
}
        $this
->getLayout()->getBlock('head')->setTitle($this->__('Newsletter Subscription'));
        
$this->renderLayout();
    
}

    
public function saveAction()
    
{
        
try {
            Mage
::getSingleton('customer/session')->getCustomer()
                ->
setStoreId(Mage::app()->getStore()->getId())
                ->
setIsSubscribed((boolean)$this->getRequest()->getParam('is_subscribed'false))
                ->
save();
            
Mage::getSingleton('customer/session')->addSuccess($this->__('The subscription was successfully saved'));
        
}
        
catch (Exception $e{
            Mage
::getSingleton('customer/session')->addError($this->__('There was an error while saving your subscription'));
        
}
        $this
->_redirect('customer/account/');
    
}
}

Customer/Block/Newsletter.php:

class Mage_Customer_Block_Newsletter extends Mage_Customer_Block_Account_Dashboard // Mage_Core_Block_Template
{

    
public function __construct()
    
{
        parent
::__construct();
        
$this->setTemplate('customer/form/newsletter.phtml');
    
}

    
public function getIsSubscribed()
    
{
        
return $this->getSubscriptionObject()->isSubscribed();
    
}

    
public function getAction()
    
{
        
return $this->getUrl('*/*/save');
    
}

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