4

I have followed this solution Magento 2 : How to add a product grid in custom module using ui component? but i am getting this

enter image description here

What i am doing wrong can any one help me on this. Edit Controller

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;
}


}
  • I think the css file of page is not coming. Can you check the console and also try running content deploy, cache and indexing commands – surbhi agr May 9 at 7:07
0

Try this, it seems to be working http://www.webspeaks.in/2016/05/magento-2-add-products-grid-to-custom-admin-module.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.