示例#1
0
 /**
  * Get product reviews grid
  *
  * @return void
  */
 public function execute()
 {
     $product = $this->productBuilder->build($this->getRequest());
     $this->_view->loadLayout();
     $this->_view->getLayout()->getBlock('admin.product.reviews')->setProductId($product->getId())->setUseAjax(true);
     $this->_view->renderLayout();
 }
示例#2
0
 /**
  * Post new product
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     $resultRedirect = $this->resultRedirectFactory->create();
     $request = $this->getRequest();
     $post = $request->getPostValue();
     if (!$post) {
         $resultRedirect->setPath('*/*/');
         return $resultRedirect;
     }
     /** @var \TurgayOzgur\C2C\Model\ProductFromCustomer $product */
     $product = $this->initializationHelper->initialize($this->productBuilder->build($request));
     $this->productTypeManager->processProduct($product);
     $imagePaths = $request->getParam('image');
     if ($imagePaths) {
         $isFirst = true;
         foreach ($imagePaths as $path) {
             $product->addImageToMediaGallery($path, $isFirst ? ['image', 'small_image', 'thumbnail'] : null, false, false);
             $isFirst = false;
         }
     }
     $product->setTypeId('simple');
     // Simple.
     $product->setAttributeSetId(4);
     // Default.
     $product->setStatus(1);
     // 1 - Enable, 2 - Disable.
     $product->setVisibility(4);
     $product->setSku($product->getName());
     $product->setCustomerId($this->_getSession()->getCustomerId());
     $product->save();
     $resultRedirect->setPath('C2C/customerproducts');
     return $resultRedirect;
 }
示例#3
0
 /**
  * Get product reviews grid
  *
  * @return \Magento\Framework\View\Result\Layout
  */
 public function execute()
 {
     $product = $this->productBuilder->build($this->getRequest());
     /** @var \Magento\Framework\View\Result\Layout $resultLayout */
     $resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT);
     $resultLayout->getLayout()->getBlock('admin.product.reviews')->setProductId($product->getId())->setUseAjax(true);
     return $resultLayout;
 }
 /**
  * Add "super" attribute from popup window
  *
  * @return void
  */
 public function execute()
 {
     $this->_view->loadLayout('popup');
     $this->productBuilder->build($this->getRequest());
     $attributeBlock = $this->_view->getLayout()->createBlock('Magento\\ConfigurableProduct\\Block\\Adminhtml\\Product\\Attribute\\NewAttribute\\Product\\Created');
     $this->_addContent($attributeBlock);
     $this->_view->renderLayout();
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $this->productBuilder->build($this->getRequest());
     /** @var \Magento\Framework\View\Result\Layout $resultLayout */
     $resultLayout = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
     $resultLayout->getLayout()->getUpdate()->removeHandle('default');
     return $resultLayout;
 }
示例#6
0
文件: Index.php 项目: aiesh/magento2
 /**
  * Generate product variations matrix
  *
  * @return void
  */
 public function execute()
 {
     $this->_saveAttributeOptions();
     $this->getRequest()->setParam('variations-matrix', array());
     $this->initializationHelper->initialize($this->productBuilder->build($this->getRequest()));
     $this->_view->loadLayout();
     $this->_view->renderLayout();
 }
示例#7
0
 /**
  * {@inheritdoc}
  */
 public function build(\Magento\Framework\App\RequestInterface $request)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'build');
     if (!$pluginInfo) {
         return parent::build($request);
     } else {
         return $this->___callPlugins('build', func_get_args(), $pluginInfo);
     }
 }
示例#8
0
 /**
  * get current product
  * @return \Magento\Catalog\Model\Product
  */
 public function getProduct()
 {
     if (is_null($this->_product)) {
         if ($this->registry->registry('current_product')) {
             $this->_product = $this->registry->registry('current_product');
         } else {
             $product = $this->productBuilder->build($this->getRequest());
             $this->_product = $product;
         }
     }
     return $this->_product;
 }
示例#9
0
 public function testBuildWhenProductNotExist()
 {
     $valueMap = [['id', null, null], ['store', 0, 'some_store'], ['type', null, 'type_id'], ['set', null, 3], ['store', null, 'store']];
     $this->requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap($valueMap));
     $this->productFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->productMock));
     $this->productMock->expects($this->once())->method('setStoreId')->with('some_store')->will($this->returnSelf());
     $productValueMap = [['type_id', $this->productMock], [\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE, $this->productMock]];
     $this->productMock->expects($this->any())->method('setTypeId')->will($this->returnValueMap($productValueMap));
     $this->productMock->expects($this->never())->method('load');
     $this->productMock->expects($this->once())->method('setAttributeSetId')->with(3)->will($this->returnSelf());
     $registryValueMap = [['product', $this->productMock, $this->registryMock], ['current_product', $this->productMock, $this->registryMock]];
     $this->registryMock->expects($this->any())->method('register')->will($this->returnValueMap($registryValueMap));
     $this->wysiwygConfigMock->expects($this->once())->method('setStoreId')->with('store');
     $this->assertEquals($this->productMock, $this->builder->build($this->requestMock));
 }
示例#10
0
 /**
  * @inheritdoc
  */
 public function execute()
 {
     $this->productBuilder->build($this->getRequest());
     return $this->resultFactory->create(ResultFactory::TYPE_LAYOUT);
 }
示例#11
0
 /**
  * @return void
  */
 public function execute()
 {
     $this->productBuilder->build($this->getRequest());
     $this->_view->loadLayout(false);
     $this->_view->renderLayout();
 }