I am using new product widget in my custom phtml template. It is showing the newly products. but i want to add the date filter to this products. How can i do it. Any help appreciated.

template file code:

<?php echo $this->getLayout()->createBlock("Magento\Catalog\Block\Product\Widget\NewWidget")->setDisplayType("new_products")->setProductsCount("20")->setTemplate("product/widget/new/content/new_grid.phtml")->toHtml(); ?>

I have added from and To date fields in product/widget/new/content/new_grid.phtml template but I don't know how to pass this dates to function and get filtered results. Thanks in advance. Any help appreciated.

getLayout()->createBlock("Kblikruta\Productslider\Block\Index")->setData('key', 'new')->setData('title', 'NEW ARRIVE')->setData('customtext', 'lorem')->setTemplate("Kblikruta_Productslider::productslider_grid.phtml")->toHtml(); ?>

set attribute using setData('variablename','value');

get data in you phtml file using $block->getVariablename();

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.