I am new to Magento.

I have some product ids. I have to list this product on my custom page. These products are selected from different categories. So I cant make these products in same category and display using insert widgets.

If my product ids are 23, 32, 12, 583. How can I display these products on a page?


i write the following code in my custom file (app/design/frontend/Alothemes/bencher6/Magento_Theme/templates/myphp/myphpcode.phtml)

 $_product = Mage::getModel('catalog/product')->load(20); 

and I write the block in cms section

 {{block class="Magento\Framework\View\Element\Template" template="Magento_Theme::myphp/myphpcode.phtml"}}

so I get the following error Fatal error: Uncaught Error: Class 'Mage'

Please help.

  • using hardcoded ids is bad. you should first think about what identifies these products – Philipp Sander Aug 18 '19 at 11:49
  • take a look at viewmodels – Philipp Sander Aug 18 '19 at 11:57
  • is there any extension to do this – John Aug 18 '19 at 12:12
  • i don't think you need an extension. just use widgets – Philipp Sander Aug 18 '19 at 12:39
  • please attach phtml file code – Rk Rathod Aug 19 '19 at 10:01

Your Answer

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

Browse other questions tagged or ask your own question.