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

newletter_subscriber cannot update change_status_at
 
macleon
Jr. Member
 
Total Posts:  9
Joined:  2011-07-01
 

I’ve been looking for a while at other threads, several have been close to what I need but not quite.

When a guest or customer sign up for our newsletter the field change_status_at populates with a timestamp.

However, if the guest or customer unsubscribe, we would like the the change_status_at field to pickup the current timestamp.

This is important to use because we do not use the newsletter “feature” of Magento 1.7.0.2 CE. Rather we export the newletter_subscriber list to a company to send an email.

Thank you,

Dan

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

In app\code\core\Mage\Newsletter\controllers\SubscriberController.php

Replace existing function with

public function unsubscribeAction()
    
{
        $id    
= (int) $this->getRequest()->getParam('id');
        
$code  = (string) $this->getRequest()->getParam('code');

        if (
$id && $code{
            $session 
Mage::getSingleton('core/session');
            try 
{
                Mage
::getModel('newsletter/subscriber')->load($id)
                    ->
setCheckCode($code)
                    ->
setChangeStatusAt(now()) //add this line
                    
->unsubscribe();
                
$session->addSuccess($this->__('You have been unsubscribed.'));
            
}
            
catch (Mage_Core_Exception $e{
                $session
->addException($e$e->getMessage());
            
}
            
catch (Exception $e{
                $session
->addException($e$this->__('There was a problem with the un-subscription.'));
            
}
        }
        $this
->_redirectReferer();
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
macleon
Jr. Member
 
Total Posts:  9
Joined:  2011-07-01
 

kiatng, Thank you the code worked perfect. How long have you been using Magento?

Do you love it or hate it?

Mac Leon

 
Magento Community Magento Community
Magento Community
Magento Community
 
macleon
Jr. Member
 
Total Posts:  9
Joined:  2011-07-01
 

Another thought on the above problem is that the field change_status_at doesn\’t populate when someone subscribes for the first time unless I change the structure of the table.

Do you see any problem with changing the table structure with Magento of is there a fix to fill in the time when the customer signs up for a newsletter.

Field:        change_status_at
Type:        TIMESTAMP
Length/Values1:   
Default2:        NULL

Collation: 
Attributes: 
Null:        \"CHECKED\"
AUTO_INCREMENT:
Comments:        Change Status At

macleon

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

How long have I worked with Magento? Take a look at my joined date to this forum. Do I hate it or love it? I have passion about it !

Changing structure of native table? Do it cautiously. In your case, since the evidence seems to indicate that the field is not being used, you may change it. But you may consider adding another field that do what you want. Adding fields to table is totally safe.

 
Magento Community Magento Community
Magento Community
Magento Community
 
macleon
Jr. Member
 
Total Posts:  9
Joined:  2011-07-01
 

Many thanks for your time and advice.

I’ve been working with it for a year and half. I suppose the complex nature of the files structure and database give Magento it’s power and potential, but some of it’s short comings seem careless.

I realize that the CE is really just beta testing but considering the following and community structure Magento has amassed I would think they would provide a more stable platform.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

There was a bug report on this issue: http://www.magentocommerce.com/bug-tracking/issue/?issue=13992

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