/**
  * save product data
  *
  * @param $observer
  *
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     $downloads = $this->context->getRequest()->getFiles('downloads', -1);
     if ($downloads != '-1') {
         // Get current product
         $product = $this->coreRegistry->registry('product');
         $productId = $product->getId();
         // Loop through uploaded downlaods
         foreach ($downloads as $download) {
             // Upload file
             $uploadedDownload = $this->upload->uploadFile($download);
             if ($uploadedDownload) {
                 $objectManager = $this->context->getObjectManager();
                 // Store date in database
                 $download = $objectManager->create('Sebwite\\ProductDownloads\\Model\\Download');
                 $download->setDownloadUrl($uploadedDownload['file']);
                 $download->setDownloadFile($uploadedDownload['name']);
                 $download->setDownloadType($uploadedDownload['type']);
                 $download->setProductId($productId);
                 $download->save();
             }
         }
     }
     return $this;
 }
 /**
  * Execute method.
  *
  * @param \Magento\Framework\Event\Observer $observer
  *
  * @return $this
  * @codingStandardsIgnoreStart
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     //@codingStandardsIgnoreEnd
     $groups = $this->context->getRequest()->getPost('groups');
     if (isset($groups['api']['fields']['username']['inherit']) || isset($groups['api']['fields']['password']['inherit'])) {
         return $this;
     }
     $apiUsername = isset($groups['api']['fields']['username']['value']) ? $groups['api']['fields']['username']['value'] : false;
     $apiPassword = isset($groups['api']['fields']['password']['value']) ? $groups['api']['fields']['password']['value'] : false;
     //skip if the inherit option is selected
     if ($apiUsername && $apiPassword) {
         $this->helper->log('----VALIDATING ACCOUNT---');
         $isValid = $this->test->validate($apiUsername, $apiPassword);
         if ($isValid) {
             //save endpoint for account
             foreach ($isValid->properties as $property) {
                 if ($property->name == 'ApiEndpoint' && !empty($property->value)) {
                     $this->saveApiEndpoint($property->value);
                     break;
                 }
             }
             $this->messageManager->addSuccessMessage(__('API Credentials Valid.'));
         } else {
             $this->messageManager->addWarningMessage(__('Authorization has been denied for this request.'));
         }
     }
     return $this;
 }
Example #3
0
 /**
  * save category data
  * @param $observer
  * @return $this
  */
 public function saveCategoryData($observer)
 {
     $post = $this->context->getRequest()->getPost('category_sample_news_authors', -1);
     if ($post != '-1') {
         $post = json_decode($post, true);
         $category = $this->coreRegistry->registry('category');
         $this->authorResource->saveAuthorCategoryRelation($category, $post);
     }
     return $this;
 }
Example #4
0
 /**
  * save category data
  * @param $observer
  * @return $this
  */
 public function saveCategoryData($observer)
 {
     $post = $this->context->getRequest()->getPost('category_gemtoo_blog_articles', -1);
     if ($post != '-1') {
         $post = json_decode($post, true);
         $category = $this->coreRegistry->registry('category');
         $this->articleResource->saveArticleCategoryRelation($category, $post);
     }
     return $this;
 }
 /**
  * AccountTransactionalDataCheck constructor.
  *
  * @param \Dotdigitalgroup\Email\Model\ContactFactory $contactFactory
  * @param \Dotdigitalgroup\Email\Helper\Data          $data
  * @param \Magento\Backend\App\Action\Context         $context
  * @param \Magento\Store\Model\StoreManagerInterface  $storeManagerInterface
  */
 public function __construct(\Dotdigitalgroup\Email\Model\ContactFactory $contactFactory, \Dotdigitalgroup\Email\Helper\Data $data, \Magento\Backend\App\Action\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManagerInterface)
 {
     $this->_helper = $data;
     $this->_context = $context;
     $this->_contactFactory = $contactFactory;
     $this->_request = $context->getRequest();
     $this->_storeManager = $storeManagerInterface;
     $this->messageManager = $context->getMessageManager();
 }