/**
  * Check rules that contains affected attribute
  * If rules were found they will be set to inactive and notice will be add to admin session
  *
  * @param string $attributeCode
  * @return $this
  */
 public function checkSalesRulesAvailability($attributeCode)
 {
     /* @var $collection \Magento\SalesRule\Model\ResourceModel\Rule\Collection */
     $collection = $this->_collectionFactory->create()->addAttributeInConditionFilter($attributeCode);
     $disabledRulesCount = 0;
     foreach ($collection as $rule) {
         /* @var $rule \Magento\SalesRule\Model\Rule */
         $rule->setIsActive(0);
         /* @var $rule->getConditions() \Magento\SalesRule\Model\Rule\Condition\Combine */
         $this->_removeAttributeFromConditions($rule->getConditions(), $attributeCode);
         $this->_removeAttributeFromConditions($rule->getActions(), $attributeCode);
         $rule->save();
         $disabledRulesCount++;
     }
     if ($disabledRulesCount) {
         $this->messageManager->addWarning(__('%1 Cart Price Rules based on "%2" attribute have been disabled.', $disabledRulesCount, $attributeCode));
     }
     return $this;
 }
Example #2
0
 /**
  * @param \Magento\Backend\Model\Auth $authModel
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterLogin(\Magento\Backend\Model\Auth $authModel)
 {
     $this->sessionsManager->processLogin();
     if ($this->sessionsManager->getCurrentSession()->isOtherSessionsTerminated()) {
         $this->messageManager->addWarning(__('All other open sessions for this account were terminated.'));
     }
 }
Example #3
0
 /**
  * Send email about new order.
  * Process mail exception
  *
  * @param Order $order
  * @return bool
  */
 public function send(Order $order)
 {
     try {
         $this->orderSender->send($order);
     } catch (\Magento\Framework\Mail\Exception $exception) {
         $this->logger->logException($exception);
         $this->messageManager->addWarning(__('You did not email your customer. Please check your email settings.'));
         return false;
     }
     return true;
 }
 protected function _request($request)
 {
     $requestUrl = $this->_requestUrl($request);
     $startTime = round(microtime(true) * 1000);
     $cacheId = $this->cache->getId(__METHOD__, array($request));
     if ($response = $this->cache->load($cacheId)) {
         return $this->_parseResponse($response);
     } else {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $this->_requestUrl($request));
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
         curl_setopt($ch, CURLOPT_TIMEOUT, 400);
         curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate");
         curl_setopt($ch, CURLOPT_POST, 1);
         $response = curl_exec($ch);
         curl_close($ch);
         $this->cache->save($response, $cacheId);
         if ($this->helper->isRequestDebug()) {
             $stime = round(microtime(true) * 1000) - $startTime;
             $this->messageManager->addWarning(__('Celebros Search Engine:') . '<br>' . $requestUrl . ' <br>(' . $stime . 'ms)');
         }
         return $this->_parseResponse($response);
     }
 }
 /**
  * Check if Celebros engine is available
  *
  * @return bool
  */
 public function isActiveEngine()
 {
     if ($this->engineStatus === null) {
         $engineStatus = false;
         if ($this->isEnabled()) {
             if ($this->getCurrentWorkHanlde() == 'catalog_category' && $this->isNavToSearchEnabled()) {
                 if ($this->isNavToSearchBlacklistEnabled()) {
                     $categoryId = (int) $this->_request->getParam('id', FALSE);
                     if ($categoryId) {
                         $blacklist = $this->getNavToSearchBlacklist();
                         if (!in_array($categoryId, explode(',', $blacklist))) {
                             $engineStatus = true;
                         }
                     }
                 } else {
                     $engineStatus = true;
                 }
             } elseif ($this->getCurrentWorkHanlde() == 'catalogsearch_result') {
                 $engineStatus = true;
             }
         }
         if ($this->isRequestDebug()) {
             $this->messageManager->addWarning(__('Celebros Search Engine') . ($engineStatus ? ' Enabled' : ' Disabled'));
         }
         $this->engineStatus = $engineStatus;
     }
     return $this->engineStatus;
 }
 /**
  * / ! \ Changing notice will also change return type / ! \
  * @param  string $kind
  * @param  string $url
  * @param  array $dataJson
  * @param  bool $notice
  * @return array
  */
 protected function act($kind, $url, $dataJson = [], $notice = 0)
 {
     /* Prepairing request and it's header */
     $request = $this->init($url);
     $headerArray = array('X-Key: ' . $this->_xkey, 'Content-Type: application/json');
     curl_setopt($request, CURLOPT_CUSTOMREQUEST, $kind);
     /* if POST/PUT request, add Json parameters */
     if (!empty($dataJson)) {
         $data = json_encode($dataJson);
         curl_setopt($request, CURLOPT_POSTFIELDS, $data);
         $headerArray[] = 'Content-Length: ' . strlen($data);
     }
     if (empty($dataJson) && ($kind == self::REST_POST || $kind == self::REST_PUT)) {
         $headerArray[] = 'Content-Length: 0';
     }
     /* filling header with Xkey and options */
     curl_setopt($request, CURLOPT_HTTPHEADER, $headerArray);
     /* Executing request and retrieveing infos about the request */
     $result = curl_exec($request);
     $info = curl_getinfo($request);
     /* Prepairing return variables */
     $result = $this->convertFromJson($result);
     $resultArray = array('result' => $result, 'info' => $info);
     curl_close($request);
     /* Notice user about the error and return json array of result or null if error */
     if ($notice > 0) {
         if ($resultArray['info']['http_code'] != 200 && $resultArray['info']['http_code'] != 204 && $notice > 0) {
             $text = '<p>Error ' . $tab['info']['http_code'] . ' : ""' . $kind . '"" on ' . $endUrl . ' failed.</p>';
             if ($notive == 2) {
                 /* shows up a fancy message on the [next] loading[/ed] page */
                 $this->messageManager->addWarning($text);
             } else {
                 if ($notice == 1) {
                     /* Directly echo the error on the page */
                     echo $text;
                 }
             }
             return null;
         }
         return json_encode($resultArray['result']);
     }
     /* Returns an array with all the details, including error results */
     return $resultArray;
 }
Example #7
0
 /**
  * Check rules that contains affected attribute
  * If rules were found they will be set to inactive and notice will be add to admin session
  *
  * @param string $attributeCode
  * @return $this
  */
 protected function checkCatalogRulesAvailability($attributeCode)
 {
     /* @var $collection RuleCollectionFactory */
     $collection = $this->ruleCollectionFactory->create()->addAttributeInConditionFilter($attributeCode);
     $disabledRulesCount = 0;
     foreach ($collection as $rule) {
         /* @var $rule Rule */
         $rule->setIsActive(0);
         /* @var $rule->getConditions() Combine */
         $this->removeAttributeFromConditions($rule->getConditions(), $attributeCode);
         $rule->save();
         $disabledRulesCount++;
     }
     if ($disabledRulesCount) {
         $this->ruleProductProcessor->markIndexerAsInvalid();
         $this->messageManager->addWarning(__('You disabled %1 Catalog Price Rules based on "%2" attribute.', $disabledRulesCount, $attributeCode));
     }
     return $this;
 }
Example #8
0
 public function addWarning($message, $popupText = null, $popupTitle = null)
 {
     $popupId = $this->addPopup($popupText, $popupTitle);
     $this->messageManager->addWarning($this->getMessageText($message, $popupId));
 }
Example #9
0
 /**
  * Check rules that contains affected attribute
  * If rules were found they will be set to inactive and notice will be add to admin session
  *
  * @param string $attributeCode
  * @return $this
  */
 protected function _checkCatalogRulesAvailability($attributeCode)
 {
     /* @var $collection Collection */
     $collection = $this->_ruleCollectionFactory->create()->addAttributeInConditionFilter($attributeCode);
     $disabledRulesCount = 0;
     foreach ($collection as $rule) {
         /* @var $rule Rule */
         $rule->setIsActive(0);
         /* @var $rule->getConditions() Combine */
         $this->_removeAttributeFromConditions($rule->getConditions(), $attributeCode);
         $rule->save();
         $disabledRulesCount++;
     }
     if ($disabledRulesCount) {
         $this->_ruleFactory->create()->applyAll();
         $this->messageManager->addWarning(__('%1 Catalog Price Rules based on "%2" attribute have been disabled.', $disabledRulesCount, $attributeCode));
     }
     return $this;
 }