Пример #1
0
    /**
     * Adds configured product to quote
     *
     * @return \Magento\Backend\Model\View\Result\Redirect
     */
    public function executeInternal()
    {
        $errorMessage = null;
        try {
            $this->_initSession()->_processData();
        } catch (\Exception $e) {
            $this->_reloadQuote();
            $errorMessage = $e->getMessage();
        }

        // Form result for client javascript
        $updateResult = new \Magento\Framework\DataObject();
        if ($errorMessage) {
            $updateResult->setError(true);
            $updateResult->setMessage($errorMessage);
        } else {
            $updateResult->setOk(true);
        }

        $updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname'));
        $this->_objectManager->get('Magento\Backend\Model\Session')->setCompositeProductResult($updateResult);
        /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();
        return $resultRedirect->setPath('catalog/product/showUpdateResult');
    }
Пример #2
0
 /**
  * IFrame handler for submitted configuration for wishlist item.
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function executeInternal()
 {
     // Update wishlist item
     $updateResult = new \Magento\Framework\DataObject();
     try {
         $this->_initData();
         $buyRequest = new \Magento\Framework\DataObject($this->getRequest()->getParams());
         $this->_wishlist->updateItem($this->_wishlistItem->getId(), $buyRequest)->save();
         $updateResult->setOk(true);
     } catch (Exception $e) {
         $updateResult->setError(true);
         $updateResult->setMessage($e->getMessage());
     }
     $updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname'));
     $this->_objectManager->get('Magento\\Backend\\Model\\Session')->setCompositeProductResult($updateResult);
     return $this->resultRedirectFactory->create()->setPath('catalog/product/showUpdateResult');
 }