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

Different Newsletter categories (Error calling $this->getStores())
 
Dieter21
Member
 
Avatar
Total Posts:  51
Joined:  2008-03-29
Belgium
 

Hello everyone,

I am trying to give a customer the ability to subscribe to several categories of newsletters.
I am making a webshop for a sportstore and I want the customer to be able to choose between newsletters with subjects:
- General Subscription
- windsurfing
- snowboarding
- skiïng
- kite-ing
- ...

In the file app\design\frontend\default\default\template\customer\form\newsletter.phtml I want to place a checkbox for every existing store in my Magento database.

I tried to add the following code at line 27:

<?php foreach ($this->getStores() as $_store
{
echo $_store->getName() ;
}
?>

The above code is for test purposal to try and enumerate all the store names.
I get the following error:

Warning: Invalid argument supplied for foreach() in C:\wamp\www\magento_1_1_0\app\design\frontend\default\default\template\customer\form\newsletter.phtml on line 28

Can someone explain me why this doesn’t work in newsletter.phtml and why it does work in app\code\core\Mage\Page\Block\Switch.php for example?

Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
MAGNETO.ME
Jr. Member
 
Total Posts:  12
Joined:  2008-09-09
 

Try :

$stores =  Mage::app()->getWebsite()->getStores();
 
Magento Community Magento Community
Magento Community
Magento Community
 
Ella S.
Jr. Member
 
Total Posts:  21
Joined:  2009-06-29
 

Hi Dieter,

Can you explain how you’ve done this?

Thanks!
Ella S.

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