registry = $registry; $this->factory = $factory; $this->logger = $logger; parent::__construct($context); } /** * Get associated grouped products grid popup * * @return \Magento\Framework\View\Result\Layout */ public function execute() { $productId = (int)$this->getRequest()->getParam('id'); /** @var $product \Magento\Catalog\Model\Product */ $product = $this->factory->create(); $product->setStoreId($this->getRequest()->getParam('store', 0)); $typeId = $this->getRequest()->getParam('type'); if (!$productId && $typeId) { $product->setTypeId($typeId); } $product->setData('_edit_mode', true); if ($productId) { try { $product->load($productId); } catch (\Exception $e) { $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE); $this->logger->critical($e); } } $setId = (int)$this->getRequest()->getParam('set'); if ($setId) { $product->setAttributeSetId($setId); } $this->registry->register('current_product', $product); /** @var \Magento\Framework\View\Result\Layout $resultLayout */ $resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT); return $resultLayout; } }