protected function _prepareCollection() { $collection = Mage::getModel('mailinglist/subscription')->getCollection(); Mage::fireLog($collection, "Collection"); $this->setCollection($collection); return parent::_prepareCollection(); }
public function initForm() { $form = new Varien_Data_Form(); $form->setHtmlIdPrefix('_mailinglist'); $customer = Mage::registry('current_customer'); Mage::register('lex_customer', $customer); Mage::fireLog($customer, "Set Customer"); $helper = Mage::helper('mailinglist'); $helper->setSelectedCustomer($customer); $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer); //Mage::register('subscriber', $subscriber); if ($customer->getWebsiteId() == 0) { $this->setForm($form); return $this; } $fieldset->addField('subscription', 'checkbox', array('label' => Mage::helper('customer')->__('Subscribed to Newsletter?'), 'name' => 'subscription')); if ($customer->isReadonly()) { $form->getElement('subscription')->setReadonly(true, true); } // $form->getElement('subscription')->setIsChecked($subscriber->isSubscribed()); /* if($changedDate = $this->getStatusChangedDate()) { $fieldset->addField('change_status_date', 'label', array( 'label' => $subscriber->isSubscribed() ? Mage::helper('customer')->__('Last Date Subscribed') : Mage::helper('customer')->__('Last Date Unsubscribed'), 'value' => $changedDate, 'bold' => true ) ); } */ $this->setForm($form); return $this; }
public function addSubscriber(Varien_Event_Observer $observer) { //Mage::fireLog("Add Subscriber", "Observer"); $helper = Mage::helper('core'); $controller = $observer->getEvent()->getControllerAction(); //$controller = $observer->getEvent(); Mage::fireLog($controller); Mage::fireLog("It Works!", "Observer"); $request = $controller->getRequest(); $params = $request->getParams(); Mage::fireLog($params, "Params"); }
/** * Categories tree node (Ajax version) */ public function categoriesJsonAction() { if ($categoryId = (int) $this->getRequest()->getPost('id')) { Mage::fireLog($categoryId); $category = Mage::getModel('catalog/category')->load($categoryId); if ($category->getId()) { Mage::register('category', $category); Mage::register('current_category', $category); } $this->getResponse()->setBody($this->_getCategoryTreeBlock()->getTreeJson($category)); } }
public function loadByCustomer(Mage_Customer_Model_Customer $customer) { $data = $this->getResource()->loadByCustomer($customer); $this->addData($data); if (!empty($data) && $customer->getId() && !$this->getCustomerId()) { $this->setCustomerId($customer->getId()); Mage::fireLog($customer->getId()); $this->setSubscriberConfirmCode($this->randomSequence()); if ($this->getStatus() == self::STATUS_NOT_ACTIVE) { $this->setStatus($customer->getIsSubscribed() ? self::STATUS_SUBSCRIBED : self::STATUS_UNSUBSCRIBED); } $this->save(); } return $this; }
/** * Load subscriber by customer * * @param Mage_Customer_Model_Customer $customer * @return array */ public function loadByCustomer(Mage_Customer_Model_Customer $customer) { $select = $this->_read->select()->from($this->getMainTable())->where('customer_id=:customer_id'); Mage::fireLog($customer->getId(), "loadByCustomer"); $result = $this->_read->fetchRow($select, array('customer_id' => $customer->getId())); if ($result) { return $result; } $select = $this->_read->select()->from($this->getMainTable())->where('subscriber_email=:subscriber_email'); $result = $this->_read->fetchRow($select, array('subscriber_email' => $customer->getEmail())); if ($result) { return $result; } return array(); }
public function unsubscribeAction() { $helper = Mage::helper('mailinglist'); $customer = $helper->getSelectedCustomer(); $subscribers = $this->getRequest()->getParam('id'); //print_r($subscribersIds); //die(); // $subscribers = explode(",", $subscribersIds); $helper = Mage::helper('mailinglist'); foreach ($subscribers as $subscriber) { $split = explode(":", $subscriber); $customer_id = $split[0]; $email = $split[1]; $lid = $split[2]; Mage::fireLog($email . ":" . $lid, "Unsubscribe Subscriber"); $options = array('email' => $email, 'listid' => $lid); $helper->unsubscribeSubscriber($options); } $this->_redirect("*/customer/edit/id/{$customer_id}"); }
public function ajaxsubscribeAction() { $form_values = $_REQUEST; Mage::fireLog($form_values, "Lexiconn_Mailinglist_IndexController - subscribeAction()"); $email = $form_values['email']; $lid = $form_values['listid']; $helper = Mage::helper('mailinglist'); $options = array("email" => $email, "listid" => $lid); if ($helper->subscriberExists($email)) { Mage::fireLog("Subscriber Exists", "Lexiconn_Mailinglist_IndexController"); $output = array("success" => "false", "message" => "Subscriber Exists"); echo json_encode($output); } else { if ($helper->addSubscriber($form_values)) { Mage::fireLog("Subscriber Does Not Exist", "Lexiconn_Mailinglist_IndexController"); $output = array("success" => "true", "message" => "Added Subscriber"); echo json_encode($output); } else { $output = array("success" => "false", "message" => "Error"); echo json_encode($output); } } }
public function changeSubscriber(Varien_Event_Observer $observer) { $event = $observer->getEvent(); Mage::fireLog($event, "changeSubscriber"); return $this; }
/** * Adds some extra params to categories collection * * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */ public function getCategoryCollection() { Mage::fireLog(parent::getCategoryCollection()->addAttributeToSelect('url_key')->addAttributeToSelect('is_anchor'), "Lexiconn_Mailinglist_Block_Adminhtml_Catalog_Category_Widget_Chooser"); return parent::getCategoryCollection()->addAttributeToSelect('url_key')->addAttributeToSelect('is_anchor'); }