Search and Filter Redirecting to 404 in Custom Product Grid in Magento 2 – Fix

filtermagento2.4.3.p1product-gridproductssearch

I have created a custom product grid in my custom module form successfully Like below.

enter image description here

Existing products are showing fine which i saved. When i want to try search for another product i am redirecting to a 404 page. This is only happens in the server. Local host 2 instances working fine. Can anyone help me any suggestion to check this and fix this issue.

Magento version 2.4.3-p1

Best Answer

I would like to update the fix. It was a spelling mistake on the module name in the grid controller. My module name was HomeTry, but i have updated the block class as Hometry. My local environment was based MAC and server is Linux, Its case sensitive. Care fully handle when naming and using it in the code.

Existing code

public function execute(){
    $resultRaw = $this->resultRawFactory->create();
    return $resultRaw->setContents(
        $this->layoutFactory->create()->createBlock(
            \Ayakil\Hometry\Block\Adminhtml\HTO\Tab\Products::class,
            'hto.assignproducts'
        )->toHtml()
    );
}

Fixed code

public function execute(){
    $resultRaw = $this->resultRawFactory->create();
    return $resultRaw->setContents(
        $this->layoutFactory->create()->createBlock(
            \Ayakil\HomeTry\Block\Adminhtml\HTO\Tab\Products::class,
            'hto.assignproducts'
        )->toHtml()
    );
}
Related Topic