首页>Magento>source

我已经按照这个解决方案

我做错了可以帮助我。 编辑控制器

class Edit extends Action
{
protected $resultRawFactory;
/**
 * @var \Magento\Framework\View\LayoutFactory
 */
protected $layoutFactory;
public function __construct(
    Action\Context $context,
    \Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
    \Magento\Framework\View\LayoutFactory $layoutFactory
)
{
    parent::__construct($context);
    $this->_outfitFactory = $celebrityFactory;
    $this->resultRawFactory = $resultRawFactory;
    $this->layoutFactory = $layoutFactory;
}
/**
 * Execute action based on request and return result
 *
 * Note: Request will be added as operation argument in future
 *
 * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface
 * @throws \Magento\Framework\Exception\NotFoundException
 */
public function execute()
{
    try {
        $resultRaw = $this->resultRawFactory->create();
        return $resultRaw->setContents(
            $this->layoutFactory->create()->createBlock(
                'Allure\Celebrities\Block\Adminhtml\Products\Edit\Tab\Product',
                'category.product.grid'
            )->toHtml()
        );  
    }
    catch (\Exception $exception) {
        $this->messageManager->addErrorMessage($exception->getMessage());
    }
    $this->_redirect("*/celebrities/index");
    return;
}
protected function _initItem($getRootInstead = false)
{
    $id = (int)$this->getRequest()->getParam('id', false);
    $myModel = $this->_objectManager->create('Allure\Celebrities\Model\Celebrity');
    if ($id) {
        $myModel->load($id);
    }
    $this->_objectManager->get('Magento\Framework\Registry')->register('item', $myModel);
    $this->_objectManager->get('Magento\Framework\Registry')->register('my_item', $myModel);
    $this->_objectManager->get('Magento\Cms\Model\Wysiwyg\Config');
    return $myModel;
}

}
最新回答
  • 2019-12-5
    1 #

    试试这个,似乎工作正常 http://www.webspeaks.in/2016/05/magento-2-add-products-grid-to-custom-admin-module.html

  • Magento Page Speed
  • magento2:Magento 2:为什么我的多商店不加载CSS?