/** * @param $storeId */ public function _processBirthday($storeId) { $days = $this->_helper->getConfig(Config::BIRTHDAY_DAYS, $storeId); $customerGroups = explode(",", $this->_helper->getConfig(Config::BIRTHDAY_CUSTOMER_GROUPS, $storeId)); $senderId = $this->_helper->getConfig(Config::GENERAL_SENDER, $storeId); $sender = array('name' => $this->_helper->getConfig("trans_email/ident_{$senderId}/name", $storeId), 'email' => $this->_helper->getConfig("trans_email/ident_{$senderId}/email", $storeId)); $templateId = $this->_helper->getConfig(Config::BIRTHDAY_TEMPLATE, $storeId); $mailSubject = $this->_helper->getConfig(Config::BIRTHDAY_SUBJECT, $storeId); $tags = $this->_helper->getConfig(Config::BIRTHDAY_MANDRILL_TAG, $storeId) . "_{$storeId}"; $sendCoupon = $this->_helper->getConfig(Config::BIRTHDAY_COUPON, $storeId); $customerGroupsCoupon = explode(",", $this->_helper->getConfig(Config::BIRTHDAY_CUSTOMER_COUPON, $storeId)); $collection = $this->_customerCollection; $date2 = date("Y-m-d H:i:s", strtotime(" + {$days} days")); $month = date("m", strtotime($date2)); $day = date("d", strtotime($date2)); $moreSelect = "MONTH(at_dob.value) = {$month} AND DAY(at_dob.value) = {$day}"; $collection->addAttributeToFilter('dob', array('neq' => 'null'))->addFieldToFilter('store_id', array('eq' => $storeId)); if (count($customerGroups)) { $collection->addFieldToFilter('group_id', array('in' => $customerGroups)); } $collection->getSelect()->where($moreSelect); $mandrillHelper = $this->_objectManager->get('\\Ebizmarts\\Mandrill\\Helper\\Data'); foreach ($collection as $customer) { $cust = $this->_objectManager->create('Magento\\Customer\\Model\\Customer')->load($customer->getEntityId()); $email = $cust->getEmail(); $name = $cust->getFirstname() . ' ' . $cust->getLastname(); if ($mandrillHelper->isSubscribed($email, 'birthday', $storeId)) { $vars = array(); $url = $this->_storeManager->getStore($storeId)->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK) . 'mandrill/autoresponder/unsubscribe?list=birthday&email=' . $email . '&store=' . $storeId; $couponCode = ''; if ($sendCoupon && in_array($customer->getGroupId(), $customerGroupsCoupon)) { if ($this->_helper->getConfig(Config::BIRTHDAY_AUTOMATIC, $storeId) == Config::COUPON_AUTOMATIC) { $this->_couponAmount = $this->_helper->getConfig(Config::BIRTHDAY_DISCOUNT, $storeId); $this->_couponExpireDays = $this->_helper->getConfig(Config::BIRTHDAY_EXPIRE, $storeId); $this->_couponType = $this->_helper->getConfig(Config::BIRTHDAY_DISCOUNT_TYPE, $storeId); $this->_couponLength = $this->_helper->getConfig(Config::BIRTHDAY_LENGTH, $storeId); $this->_couponLabel = $this->_helper->getConfig(Config::BIRTHDAY_COUPON_LABEL, $storeId); list($couponCode, $discount, $toDate) = $this->_createNewCoupon($storeId, $email, 'Birthday coupon'); $vars = array('couponcode' => $couponCode, 'discount' => $discount, 'todate' => $toDate, 'name' => $name, 'tags' => array($tags), 'url' => $url); } else { $couponCode = $this->_helper->getConfig(Config::BIRTHDAY_COUPON_CODE); $vars = array('couponcode' => $couponCode, 'name' => $name, 'tags' => array($tags), 'url' => $url); } } $transport = $this->_transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => $storeId])->setTemplateVars($vars)->setFrom($sender)->addTo($email, $name)->getTransport(); $transport->sendMessage(); $mandrillHelper->saveMail('happy birthday', $email, $name, $couponCode, $storeId); } } }
public function dobActive() { return $this->_helper->getConfig('customer/address/dob_show'); }