1

So I have a cms page which I use as a lading page. The page is custom html coded with 3 of my products (basically showing the product and the price). When you click on an "Buy Now" button it takes you to the products product page where then you can add to cart. Since the prices on the landing page are hardcoded, when the products pricing is changed the landing pages price does not change. How can I make it Dynamic so that when the products price changes... the landing pages prices will change to?

1 Answer 1

1

You can use widgets instead of hardcoded html.

Also you can call phtml from cms page and add your own code or logic for product collection and there you can easily show the dynamic price, name, images etc.

You can phtml file from cms pages by using below code:

{{block class="Magento\Framework\View\Element\Template" template="[VendorName]_[ModuleName]::[YourTemplateFileLocation].phtml"}} 

Hope this helps!

3
  • Thanks. I need a little more help with this. How can I set up the phtml page?
    – DevAnd
    Commented May 21, 2018 at 13:27
  • You can create your own product collection through object manager or collection factory and call images and price dynamically. Commented May 21, 2018 at 13:37
  • You can get an idea from here: blog.chapagain.com.np/magento-2-get-product-collection Commented May 21, 2018 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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