Skip to content

Commit

Permalink
Fixed problem of back end not working anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiagoebizmarts committed Nov 28, 2016
1 parent 26c34f9 commit fdcd348
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
protected $_coupon;

/**
* @var \Magento\SalesRule\Model\Rule
* @var \Magento\SalesRule\Model\RuleFactory
*/
protected $_rule;
protected $_ruleRepository;

/**
* @var \Ebizmarts\Mandrill\Model\Mailsent
*/
protected $_mailsent;

/**
* @var \Magento\Framework\Stdlib\DateTime\DateTime
* @var \Magento\Framework\Stdlib\DateTime\DateTimeFactory
*/
protected $_dateTime;
protected $_dateFactory;

/**
* @var \Ebizmarts\Mandrill\Model\Unsubscribe
Expand All @@ -52,27 +52,27 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
protected $_subscribed;

/**
* @param \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\SalesRule\Model\Coupon $coupon
* @param \Magento\SalesRule\Model\Rule $rule
* @param \Magento\SalesRule\Model\RuleRepository $ruleRepository
* @param \Ebizmarts\Mandrill\Model\Mailsent $mailsent
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
* @param \Ebizmarts\Mandrill\Model\Unsubscribe $unsubscribe
*/
public function __construct(
\Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory,
\Magento\Framework\App\Helper\Context $context,
\Magento\SalesRule\Model\Coupon $coupon,
\Magento\SalesRule\Model\Rule $rule,
\Magento\SalesRule\Model\RuleRepository $ruleRepository,
\Ebizmarts\Mandrill\Model\Mailsent $mailsent,
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
\Ebizmarts\Mandrill\Model\Unsubscribe $unsubscribe
)
{
$this->_logger = $context->getLogger();
$this->_coupon = $coupon;
$this->_rule = $rule;
$this->_ruleRepository = $ruleRepository;
$this->_mailsent = $mailsent;
$this->_dateTime = $dateTime;
$this->_dateFactory = $dateFactory;
$this->_unsubscribe = $unsubscribe;
$this->_subscribed = array();
parent::__construct($context);
Expand Down Expand Up @@ -121,7 +121,7 @@ public function saveMail($mailType,$mail,$name,$couponCode,$storeId)
{
if ($couponCode != '') {
$coupon = $this->_coupon->loadByCode($couponCode);
$rule = $this->_rule->load($coupon->getRuleId());
$rule = $this->_ruleRepository->getById($coupon->getRuleId());
$couponAmount = $rule->getDiscountAmount();
switch ($rule->getSimpleAction()) {
case 'cart_fixed':
Expand All @@ -139,15 +139,15 @@ public function saveMail($mailType,$mail,$name,$couponCode,$storeId)
$couponAmount = 0;
}
$sent = $this->_mailsent;
$date = $this->_dateTime;
$date = $this->_dateFactory->create()->gmtDate();
$sent->setMailType($mailType)
->setStoreId($storeId)
->setCustomerEmail($mail)
->setCustomerName($name)
->setCouponNumber($couponCode)
->setCouponType($couponType)
->setCouponAmount($couponAmount)
->setSentAt($date->gmtDate())
->setSentAt($date)
->save();
}
public function isSubscribed($email, $list, $storeId)
Expand All @@ -167,17 +167,17 @@ public function isSubscribed($email, $list, $storeId)
* @param $storeId
* @return bool
*/
private function _checkSubscription($email, $list, $storeId){
$collection = $this->_unsubscribe->getCollection();
$collection->addFieldToFilter('main_table.email', array('eq' => $email))
->addFieldToFilter('main_table.list', array('eq' => $list))
->addFieldToFilter('main_table.store_id', array('eq' => $storeId));
if ($collection->getSize() == 0) {
$this->_subscribed[$storeId][$list][$email] = 'true';
return true;
} else {
$this->_subscribed[$storeId][$list][$email] = 'false';
return false;
}
}
// private function _checkSubscription($email, $list, $storeId){
// $collection = $this->_unsubscribe->getCollection();
// $collection->addFieldToFilter('main_table.email', array('eq' => $email))
// ->addFieldToFilter('main_table.list', array('eq' => $list))
// ->addFieldToFilter('main_table.store_id', array('eq' => $storeId));
// if ($collection->getSize() == 0) {
// $this->_subscribed[$storeId][$list][$email] = 'true';
// return true;
// } else {
// $this->_subscribed[$storeId][$list][$email] = 'false';
// return false;
// }
// }
}

0 comments on commit fdcd348

Please sign in to comment.