Example #1
11
 /**
  * exec post user question
  * @return void
  * @throws \Exception
  */
 public function execute()
 {
     $post = $this->getRequest()->getPostValue();
     if (!$post) {
         $this->_redirect('*/*/');
         return;
     }
     $this->inlineTranslation->suspend();
     try {
         $postObject = new \Magento\Framework\DataObject();
         $postObject->setData($post);
         $error = false;
         /* validate-checking */
         if (!\Zend_Validate::is(trim($post['name']), 'NotEmpty')) {
             $error = true;
         }
         if (!\Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
             $error = true;
         }
         if (!\Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
             $error = true;
         }
         /**
          * setting custome param
          * add new elements : product_name & product_sku information
          */
         if (array_key_exists('product_name', $post) && array_key_exists('product_sku', $post)) {
             if (!\Zend_Validate::is(trim($post['product_name']), 'NotEmpty')) {
                 $error = true;
             }
             if (!\Zend_Validate::is(trim($post['product_sku']), 'NotEmpty')) {
                 $error = true;
             }
         }
         /* this column, hideit, is not so sure for using during this process, so I close it temporarily....
            if (!\Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
                    $error = true;
            }*/
         if ($error) {
             throw new \Exception();
             //todo
         }
         /* Transport email to user */
         $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
         $transport = $this->_transportBuilder->setTemplateIdentifier($this->scopeConfig->getValue(self::XML_PATH_EMAIL_TEMPLATE, $storeScope))->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['data' => $postObject])->setFrom($this->scopeConfig->getValue(self::XML_PATH_EMAIL_SENDER, $storeScope))->addTo($this->scopeConfig->getValue(self::XML_PATH_EMAIL_RECIPIENT, $storeScope))->setReplyTo($post['email'])->getTransport();
         $transport->sendMessage();
         $this->inlineTranslation->resume();
         $this->messageManager->addSuccess(__('Hi there, this is Optoma, and thanks for your contacting with us about your questions by nice information, and we will notify you very     soon, see you next time~'));
         /* redirect to new page :: pending */
         $this->_redirect('contact/index');
         return;
     } catch (\Exception $e) {
         /* Error Log should be noted here */
         $this->inlineTranslation->resume();
         $this->messageManager->addError(__('Hi there, this is Optoma, so sorry for that we just cant\'t process your request right now, please wait a minutes and we will contact y    ou very soon~'));
         $this->_redirect('contact/index');
         //todo
         return;
     }
 }
Example #2
1
 /**
  * Post user question
  *
  * @return void
  * @throws \Exception
  */
 public function execute()
 {
     $post = $this->getRequest()->getPostValue();
     if (!$post) {
         $this->_redirect('*/*/');
         return;
     }
     $this->inlineTranslation->suspend();
     try {
         $postObject = new \Magento\Framework\DataObject();
         $postObject->setData($post);
         $error = false;
         if (!\Zend_Validate::is(trim($post['contact_email']), 'EmailAddress')) {
             $error = true;
         }
         if (!\Zend_Validate::is(trim($post['contact_question']), 'NotEmpty')) {
             $error = true;
         }
         if ($error) {
             throw new \Exception();
         }
         $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
         $transport = $this->_transportBuilder->setTemplateIdentifier($this->scopeConfig->getValue(self::XML_PATH_EMAIL_TEMPLATE, $storeScope))->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['data' => $postObject])->setFrom($this->scopeConfig->getValue(self::XML_PATH_EMAIL_SENDER, $storeScope))->addTo($this->scopeConfig->getValue(self::XML_PATH_EMAIL_RECIPIENT, $storeScope))->setReplyTo($post['contact_email'])->getTransport();
         $transport->sendMessage();
         $this->inlineTranslation->resume();
         $this->messageManager->addSuccess(__('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.'));
         $this->_redirect('delivery-charges');
         return;
     } catch (\Exception $e) {
         $this->inlineTranslation->resume();
         $this->messageManager->addError(__('We can\'t process your request right now. Sorry, that\'s all we know.'));
         $this->_redirect('delivery-charges');
         return;
     }
 }
 /**
  * @param array $data
  * @param bool $result
  * @param array $messages
  *
  * @covers \Magento\Framework\View\Design\Theme\Validator::validate
  * @dataProvider dataProviderValidate
  */
 public function testValidate(array $data, $result, array $messages)
 {
     /** @var $themeMock \Magento\Framework\DataObject */
     $themeMock = new \Magento\Framework\DataObject();
     $themeMock->setData($data);
     $validator = new \Magento\Framework\View\Design\Theme\Validator();
     $this->assertEquals($result, $validator->validate($themeMock));
     $this->assertEquals($messages, $validator->getErrorMessages());
 }
 /**
  * Build response for ajax request
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param \Magento\Backend\Model\View\Result\Page $resultPage
  *
  * @return \Magento\Framework\Controller\Result\Json
  *
  * @deprecated
  */
 protected function ajaxRequestResponse($category, $resultPage)
 {
     // prepare breadcrumbs of selected category, if any
     $breadcrumbsPath = $category->getPath();
     if (empty($breadcrumbsPath)) {
         // but if no category, and it is deleted - prepare breadcrumbs from path, saved in session
         $breadcrumbsPath = $this->_objectManager->get('Magento\\Backend\\Model\\Auth\\Session')->getDeletedPath(true);
         if (!empty($breadcrumbsPath)) {
             $breadcrumbsPath = explode('/', $breadcrumbsPath);
             // no need to get parent breadcrumbs if deleting category level 1
             if (count($breadcrumbsPath) <= 1) {
                 $breadcrumbsPath = '';
             } else {
                 array_pop($breadcrumbsPath);
                 $breadcrumbsPath = implode('/', $breadcrumbsPath);
             }
         }
     }
     $eventResponse = new \Magento\Framework\DataObject(['content' => $resultPage->getLayout()->getUiComponent('category_form')->getFormHtml() . $resultPage->getLayout()->getBlock('category.tree')->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'), 'messages' => $resultPage->getLayout()->getMessagesBlock()->getGroupedHtml(), 'toolbar' => $resultPage->getLayout()->getBlock('page.actions.toolbar')->toHtml()]);
     $this->_eventManager->dispatch('category_prepare_ajax_response', ['response' => $eventResponse, 'controller' => $this]);
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->_objectManager->get('Magento\\Framework\\Controller\\Result\\Json');
     $resultJson->setHeader('Content-type', 'application/json', true);
     $resultJson->setData($eventResponse->getData());
     return $resultJson;
 }
Example #5
0
 public function execute()
 {
     $redirectUrl = $this->getUrl('wirecardcheckoutpage/fundtransfer/transfer');
     if (!($data = $this->getRequest()->getPostValue())) {
         $this->_redirect($redirectUrl);
         return;
     }
     $postObject = new \Magento\Framework\DataObject();
     $postObject->setData($data);
     $this->_session->setWirecardCheckoutPageFundTrandsferFormData($postObject);
     try {
         $return = $this->_fundTransferModel->sendrequest($postObject);
         if ($return->hasFailed()) {
             $this->messageManager->addErrorMessage($return->getError()->getMessage());
         } else {
             $this->_logger->debug(__METHOD__ . ':' . print_r($postObject->getData(), true));
             $this->_session->unsWirecardCheckoutPageFundTrandsferFormData();
             $this->messageManager->addNoticeMessage($this->_dataHelper->__('Fund transfer submitted successfully!'));
             $this->messageManager->addNoticeMessage($this->_dataHelper->__('Credit number' . ':' . $return->getCreditNumber()));
         }
     } catch (\Exception $e) {
         $this->messageManager->addErrorMessage($e->getMessage());
     }
     $this->_redirect($redirectUrl);
 }
Example #6
0
 /**
  * Update attribute values for entity list per store
  *
  * @param array $entityIds
  * @param array $attrData
  * @param int $storeId
  * @return $this
  * @throws \Exception
  */
 public function updateAttributes($entityIds, $attrData, $storeId)
 {
     $object = new \Magento\Framework\DataObject();
     $object->setStoreId($storeId);
     $this->getConnection()->beginTransaction();
     try {
         foreach ($attrData as $attrCode => $value) {
             $attribute = $this->getAttribute($attrCode);
             if (!$attribute->getAttributeId()) {
                 continue;
             }
             $i = 0;
             foreach ($entityIds as $entityId) {
                 $i++;
                 $object->setId($entityId);
                 $object->setEntityId($entityId);
                 // collect data for save
                 $this->_saveAttributeValue($object, $attribute, $value);
                 // save collected data every 1000 rows
                 if ($i % 1000 == 0) {
                     $this->_processAttributeValues();
                 }
             }
             $this->_processAttributeValues();
         }
         $this->getConnection()->commit();
     } catch (\Exception $e) {
         $this->getConnection()->rollBack();
         throw $e;
     }
     return $this;
 }
Example #7
0
 public function testFactory()
 {
     $product = new \Magento\Framework\DataObject();
     $product->setTypeId(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE);
     $type = $this->_productType->factory($product);
     $this->assertInstanceOf('\\Magento\\GroupedProduct\\Model\\Product\\Type\\Grouped', $type);
 }
 /**
  * Add attribute to attribute set
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function execute()
 {
     $request = $this->getRequest();
     $resultJson = $this->resultJsonFactory->create();
     try {
         /** @var \Magento\Eav\Model\Entity\Attribute $attribute */
         $attribute = $this->_objectManager->create('Magento\\Eav\\Model\\Entity\\Attribute')->load($request->getParam('attribute_id'));
         $attributeSet = $this->_objectManager->create('Magento\\Eav\\Model\\Entity\\Attribute\\Set')->load($request->getParam('template_id'));
         /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection $attributeGroupCollection */
         $attributeGroupCollection = $this->_objectManager->get('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Group\\Collection');
         $attributeGroupCollection->setAttributeSetFilter($attributeSet->getId());
         $attributeGroupCollection->addFilter('attribute_group_code', $request->getParam('group'));
         $attributeGroupCollection->setPageSize(1);
         $attributeGroup = $attributeGroupCollection->getFirstItem();
         $attribute->setAttributeSetId($attributeSet->getId())->loadEntityAttributeIdBySet();
         $attribute->setAttributeSetId($request->getParam('template_id'))->setAttributeGroupId($attributeGroup->getId())->setSortOrder('0')->save();
         $resultJson->setJsonData($attribute->toJson());
     } catch (\Exception $e) {
         $response = new \Magento\Framework\DataObject();
         $response->setError(false);
         $response->setMessage($e->getMessage());
         $resultJson->setJsonData($response->toJson());
     }
     return $resultJson;
 }
Example #9
0
 /**
  * AJAX customer validation action
  *
  * @return void
  */
 public function execute()
 {
     $response = new \Magento\Framework\DataObject();
     $response->setError(0);
     $errors = null;
     $userId = (int) $this->getRequest()->getParam('user_id');
     $data = $this->getRequest()->getPostValue();
     try {
         /** @var $model \Magento\User\Model\User */
         $model = $this->_userFactory->create()->load($userId);
         $model->setData($this->_getAdminUserData($data));
         $errors = $model->validate();
     } catch (\Magento\Framework\Validator\Exception $exception) {
         /* @var $error Error */
         foreach ($exception->getMessages(\Magento\Framework\Message\MessageInterface::TYPE_ERROR) as $error) {
             $errors[] = $error->getText();
         }
     }
     if ($errors !== true && !empty($errors)) {
         foreach ($errors as $error) {
             $this->messageManager->addError($error);
         }
         $response->setError(1);
         $this->_view->getLayout()->initMessages();
         $response->setHtmlMessage($this->_view->getLayout()->getMessagesBlock()->getGroupedHtml());
     }
     $this->getResponse()->representJson($response->toJson());
 }
Example #10
0
 /**
  * @covers \Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Sender::render
  */
 public function testRenderNameAndEmail()
 {
     $row = new \Magento\Framework\DataObject();
     $row->setTemplateSenderName('Sender Name');
     $row->setTemplateSenderEmail('Sender Email');
     $this->assertEquals('Sender Name [Sender Email]', $this->sender->render($row));
 }
Example #11
0
 public function sendNotification($data)
 {
     if (!$data) {
         return false;
     }
     $this->inlineTranslation->suspend();
     try {
         $postObject = new \Magento\Framework\DataObject();
         $postObject->setData($data);
         $error = false;
         $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
         /* $from = [
                'name' => '',
                'email' => ''
            ];*/
         $email_template = $this->scopeConfig->getValue('cadou/email/template');
         if (empty($email_template)) {
             $email_template = (string) 'cadou_email_template';
             // this code we have mentioned in the email_templates.xml
         }
         $transport = $this->_transportBuilder->setTemplateIdentifier($email_template)->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => $this->storeManager->getDefaultStoreView()->getId()])->setTemplateVars(['data' => $postObject, 'subject' => $data['productname']])->setFrom($this->scopeConfig->getValue('contact/email/sender_email_identity', $storeScope))->addTo($data['email'], isset($data['fullname']) ? $data['fullname'] : $data['name'])->getTransport();
         $transport->sendMessage();
         $this->inlineTranslation->resume();
         /*$this->messageManager->addSuccess(
               __('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.')
           );*/
         return TRUE;
     } catch (\Exception $e) {
         $this->inlineTranslation->resume();
         $this->messageManager->addError(__('We can\'t process your request right now. Sorry, that\'s all we know.' . $e->getMessage()));
         return FALSE;
     }
 }
 public function testGetWysiwygPluginSettings()
 {
     $jsPluginSourceUrl = 'js-plugin-source';
     $actionUrl = 'action-url';
     $assetRepoMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\Repository')->disableOriginalConstructor()->getMock();
     $urlMock = $this->getMockBuilder('Magento\\Backend\\Model\\UrlInterface')->disableOriginalConstructor()->getMock();
     $assetRepoMock->expects($this->any())->method('getUrl')->willReturn($jsPluginSourceUrl);
     $urlMock->expects($this->any())->method('getUrl')->willReturn($actionUrl);
     // Set up SUT
     $args = ['assetRepo' => $assetRepoMock, 'url' => $urlMock];
     $model = (new ObjectManager($this))->getObject('Magento\\Variable\\Model\\Variable\\Config', $args);
     $customKey = 'key';
     $customVal = 'val';
     $configObject = new \Magento\Framework\DataObject();
     $configObject->setPlugins([[$customKey => $customVal]]);
     $variablePluginConfig = $model->getWysiwygPluginSettings($configObject)['plugins'];
     $customPluginConfig = $variablePluginConfig[0];
     $addedPluginConfig = $variablePluginConfig[1];
     // Verify custom plugin config is present
     $this->assertSame($customVal, $customPluginConfig[$customKey]);
     // Verify added plugin config is present
     $this->assertContains($actionUrl, $addedPluginConfig['options']['onclick']['subject']);
     $this->assertContains($actionUrl, $addedPluginConfig['options']['url']);
     $this->assertContains($jsPluginSourceUrl, $addedPluginConfig['src']);
 }
Example #13
0
 /**
  * Action to reconfigure cart item
  *
  * @return \Magento\Framework\View\Result\Page|\Magento\Framework\Controller\Result\Redirect
  */
 public function execute()
 {
     // Extract item and product to configure
     $id = (int) $this->getRequest()->getParam('id');
     $productId = (int) $this->getRequest()->getParam('product_id');
     $quoteItem = null;
     if ($id) {
         $quoteItem = $this->cart->getQuote()->getItemById($id);
     }
     try {
         if (!$quoteItem || $productId != $quoteItem->getProduct()->getId()) {
             $this->messageManager->addError(__("We can't find the quote item."));
             return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('checkout/cart');
         }
         $params = new \Magento\Framework\DataObject();
         $params->setCategoryId(false);
         $params->setConfigureMode(true);
         $params->setBuyRequest($quoteItem->getBuyRequest());
         $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
         $this->_objectManager->get('Magento\\Catalog\\Helper\\Product\\View')->prepareAndRender($resultPage, $quoteItem->getProduct()->getId(), $this, $params);
         return $resultPage;
     } catch (\Exception $e) {
         $this->messageManager->addError(__('We cannot configure the product.'));
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         return $this->_goBack();
     }
 }
 /**
  * Assign data to info model instance
  *
  * @param \Magento\Framework\DataObject|mixed $data
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function assignData(\Magento\Framework\DataObject $data)
 {
     if (!$data instanceof \Magento\Framework\DataObject) {
         $data = new \Magento\Framework\DataObject($data);
     }
     $this->getInfoInstance()->setPoNumber($data->getPoNumber());
     return $this;
 }
Example #15
0
 /**
  * Tests \Magento\Framework\DataObject->__construct()
  */
 public function testConstruct()
 {
     $object = new \Magento\Framework\DataObject();
     $this->assertEquals([], $object->getData());
     $data = ['test' => 'test'];
     $object = new \Magento\Framework\DataObject($data);
     $this->assertEquals($data, $object->getData());
 }
Example #16
0
 /**
  * Prepare page object
  *
  * @param array $data
  * @return \Magento\Framework\DataObject
  */
 protected function _prepareObject(array $data)
 {
     $object = new \Magento\Framework\DataObject();
     $object->setId($data[$this->getIdFieldName()]);
     $object->setUrl($data['url']);
     $object->setUpdatedAt($data['updated_at']);
     return $object;
 }
Example #17
0
 /**
  * AJAX category validation action
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function execute()
 {
     $response = new \Magento\Framework\DataObject();
     $response->setError(0);
     $resultJson = $this->resultJsonFactory->create();
     $resultJson->setData($response);
     return $resultJson;
 }
Example #18
0
 /**
  * @covers \Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Action::render
  */
 public function testRender()
 {
     $this->columnMock->expects($this->once())->method('setActions');
     $this->columnMock->expects($this->once())->method('getActions')->willReturn(['url', 'popup', 'caption']);
     $this->action->setColumn($this->columnMock);
     $row = new \Magento\Framework\DataObject();
     $row->setId(1);
     $this->assertContains('admin__control-select', $this->action->render($row));
 }
Example #19
0
    /**
     * Action to reconfigure wishlist item
     *
     * @return \Magento\Framework\Controller\ResultInterface
     * @throws NotFoundException
     */
    public function executeInternal()
    {
        $id = (int)$this->getRequest()->getParam('id');
        /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
        $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
        try {
            /* @var $item \Magento\Wishlist\Model\Item */
            $item = $this->_objectManager->create('Magento\Wishlist\Model\Item');
            $item->loadWithOptions($id);
            if (!$item->getId()) {
                throw new \Magento\Framework\Exception\LocalizedException(
                    __('We can\'t load the Wish List item right now.')
                );
            }
            $wishlist = $this->wishlistProvider->getWishlist($item->getWishlistId());
            if (!$wishlist) {
                throw new NotFoundException(__('Page not found.'));
            }

            $this->_coreRegistry->register('wishlist_item', $item);

            $params = new \Magento\Framework\DataObject();
            $params->setCategoryId(false);
            $params->setConfigureMode(true);
            $buyRequest = $item->getBuyRequest();
            if (!$buyRequest->getQty() && $item->getQty()) {
                $buyRequest->setQty($item->getQty());
            }
            if ($buyRequest->getQty() && !$item->getQty()) {
                $item->setQty($buyRequest->getQty());
                $this->_objectManager->get('Magento\Wishlist\Helper\Data')->calculate();
            }
            $params->setBuyRequest($buyRequest);
            /** @var \Magento\Framework\View\Result\Page $resultPage */
            $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
            $this->_objectManager->get(
                'Magento\Catalog\Helper\Product\View'
            )->prepareAndRender(
                $resultPage,
                $item->getProductId(),
                $this,
                $params
            );

            return $resultPage;
        } catch (\Magento\Framework\Exception\LocalizedException $e) {
            $this->messageManager->addError($e->getMessage());
            $resultRedirect->setPath('*');
            return $resultRedirect;
        } catch (\Exception $e) {
            $this->messageManager->addError(__('We can\'t configure the product right now.'));
            $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
            $resultRedirect->setPath('*');
            return $resultRedirect;
        }
    }
Example #20
0
 /**
  * Convert actions to html
  *
  * @param array $actions
  * @return string
  */
 protected function _actionsToHtml(array $actions)
 {
     $html = [];
     $attributesObject = new \Magento\Framework\DataObject();
     foreach ($actions as $action) {
         $attributesObject->setData($action['@']);
         $html[] = '<a ' . $attributesObject->serialize() . '>' . $action['#'] . '</a>';
     }
     return implode(' <span class="separator">&nbsp;|&nbsp;</span> ', $html);
 }
Example #21
0
 /**
  * Initialize requested product object
  *
  * @return ModelProduct
  */
 protected function _initProduct()
 {
     $categoryId = (int) $this->getRequest()->getParam('category', false);
     $productId = (int) $this->getRequest()->getParam('id');
     $params = new \Magento\Framework\DataObject();
     $params->setCategoryId($categoryId);
     /** @var \Magento\Catalog\Helper\Product $product */
     $product = $this->_objectManager->get('Magento\\Catalog\\Helper\\Product');
     return $product->initProduct($productId, $this, $params);
 }
Example #22
0
 public function testRenderConfigureResultNotOK()
 {
     $configureResult = new \Magento\Framework\DataObject();
     $configureResult->setError(true)->setMessage('Test Message');
     $this->helper->renderConfigureResult($configureResult);
     $customerId = $this->registry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
     $this->assertNull($customerId);
     $errorMessage = $this->registry->registry('composite_configure_result_error_message');
     $this->assertEquals('Test Message', $errorMessage);
 }
Example #23
0
 protected function setUp()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->testData = ['before_element_html' => 'test_before_element_html', 'html_id' => 'test_id', 'name' => 'test_name', 'value' => 'test_value', 'title' => 'test_title', 'disabled' => true, 'after_element_js' => 'test_after_element_js', 'after_element_html' => 'test_after_element_html', 'html_id_prefix' => 'test_id_prefix_', 'html_id_suffix' => '_test_id_suffix'];
     $this->file = $objectManager->getObject('Magento\\Config\\Block\\System\\Config\\Form\\Field\\File', ['data' => $this->testData]);
     $formMock = new \Magento\Framework\DataObject();
     $formMock->setHtmlIdPrefix($this->testData['html_id_prefix']);
     $formMock->setHtmlIdSuffix($this->testData['html_id_suffix']);
     $this->file->setForm($formMock);
 }
Example #24
0
 /**
  * @param sring|null $typeId
  * @dataProvider factoryReturnsSingletonDataProvider
  */
 public function testFactoryReturnsSingleton($typeId)
 {
     $product = new \Magento\Framework\DataObject();
     if ($typeId) {
         $product->setTypeId($typeId);
     }
     $type = $this->_productType->factory($product);
     $otherType = $this->_productType->factory($product);
     $this->assertSame($otherType, $type);
 }
Example #25
0
 /**
  * Creates and inits block
  *
  * @param string|null $reportType
  * @return \Magento\Reports\Block\Adminhtml\Sales\Tax\Grid
  */
 protected function _createBlock($reportType = null)
 {
     $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Reports\\Block\\Adminhtml\\Sales\\Tax\\Grid');
     $filterData = new \Magento\Framework\DataObject();
     if ($reportType) {
         $filterData->setReportType($reportType);
     }
     $block->setFilterData($filterData);
     return $block;
 }
 /**
  * Ajax handler to response configuration fieldset of composite product in quote items
  *
  * @return \Magento\Framework\View\Result\Layout
  */
 public function execute()
 {
     // Prepare data
     $configureResult = new \Magento\Framework\DataObject();
     try {
         $quoteItemId = (int) $this->getRequest()->getParam('id');
         if (!$quoteItemId) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Quote item id is not received.'));
         }
         $quoteItem = $this->_objectManager->create('Magento\\Quote\\Model\\Quote\\Item')->load($quoteItemId);
         if (!$quoteItem->getId()) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Quote item is not loaded.'));
         }
         $configureResult->setOk(true);
         $optionCollection = $this->_objectManager->create('Magento\\Quote\\Model\\Quote\\Item\\Option')->getCollection()->addItemFilter([$quoteItemId]);
         $quoteItem->setOptions($optionCollection->getOptionsByItem($quoteItem));
         $configureResult->setBuyRequest($quoteItem->getBuyRequest());
         $configureResult->setCurrentStoreId($quoteItem->getStoreId());
         $configureResult->setProductId($quoteItem->getProductId());
         $sessionQuote = $this->_objectManager->get('Magento\\Backend\\Model\\Session\\Quote');
         $configureResult->setCurrentCustomerId($sessionQuote->getCustomerId());
     } catch (\Exception $e) {
         $configureResult->setError(true);
         $configureResult->setMessage($e->getMessage());
     }
     // Render page
     /** @var \Magento\Catalog\Helper\Product\Composite $helper */
     $helper = $this->_objectManager->get('Magento\\Catalog\\Helper\\Product\\Composite');
     return $helper->renderConfigureResult($configureResult);
 }
Example #27
0
 protected function setUp()
 {
     $factoryMock = $this->getMock('\\Magento\\Framework\\Data\\Form\\Element\\Factory', [], [], '', false);
     $collectionFactoryMock = $this->getMock('\\Magento\\Framework\\Data\\Form\\Element\\CollectionFactory', [], [], '', false);
     $escaperMock = $this->getMock('\\Magento\\Framework\\Escaper', [], [], '', false);
     $this->_model = new \Magento\Framework\Data\Form\Element\Column($factoryMock, $collectionFactoryMock, $escaperMock);
     $formMock = new \Magento\Framework\DataObject();
     $formMock->getHtmlIdPrefix('id_prefix');
     $formMock->getHtmlIdPrefix('id_suffix');
     $this->_model->setForm($formMock);
 }
Example #28
0
 protected function setUp()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->urlBuilderMock = $this->getMock('Magento\\Framework\\Url', [], [], '', false);
     $this->image = $objectManager->getObject('Magento\\Config\\Block\\System\\Config\\Form\\Field\\Image', ['urlBuilder' => $this->urlBuilderMock]);
     $this->testData = ['html_id_prefix' => 'test_id_prefix_', 'html_id' => 'test_id', 'html_id_suffix' => '_test_id_suffix', 'path' => 'catalog/product/placeholder', 'value' => 'test_value'];
     $formMock = new \Magento\Framework\DataObject();
     $formMock->setHtmlIdPrefix($this->testData['html_id_prefix']);
     $formMock->setHtmlIdSuffix($this->testData['html_id_suffix']);
     $this->image->setForm($formMock);
 }
Example #29
0
 /**
  * Assign data to info model instance
  *
  * @param array|\Magento\Framework\DataObject $data
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  * @api
  */
 public function assignData(\Magento\Framework\DataObject $data)
 {
     parent::assignData($data);
     if (!$data instanceof \Magento\Framework\DataObject) {
         $data = new \Magento\Framework\DataObject($data);
     }
     /** @var \Magento\Quote\Model\Quote\Payment $infoInstance */
     $infoInstance = $this->getInfoInstance();
     $infoInstance->setAdditionalInformation('financialInstitution', $data->getData('financialInstitution'));
     return $this;
 }
Example #30
0
 /**
  * Get top menu html
  *
  * @param string $outermostClass
  * @param string $childrenWrapClass
  * @param int $limit
  * @return string
  */
 public function getHtml($outermostClass = '', $childrenWrapClass = '', $limit = 0)
 {
     $this->_eventManager->dispatch('page_block_html_topmenu_gethtml_before', ['menu' => $this->_menu, 'block' => $this]);
     $this->_menu->setOutermostClass($outermostClass);
     $this->_menu->setChildrenWrapClass($childrenWrapClass);
     $html = $this->_getHtml($this->_menu, $childrenWrapClass, $limit);
     $transportObject = new \Magento\Framework\DataObject(['html' => $html]);
     $this->_eventManager->dispatch('page_block_html_topmenu_gethtml_after', ['menu' => $this->_menu, 'transportObject' => $transportObject]);
     $html = $transportObject->getHtml();
     return $html;
 }