I need to get products name and thumbnail images on cms page if customer enters sku, they get name, price, and thumbnail images.

Customer get short details using sku, if customer enter sku for given test box, they get short products details like Name, Price, Thumbnail. Is it Codeigniter worth?

  • Where the user enters the SKU ? – PЯINCƏ May 29 '17 at 12:22
  • Sorry @rathinam, could not understand your question. – Mohit Kumar Arora May 29 '17 at 12:23
  • actually need to design text box on custom cms page, when customer enter the sku on the box, they get name, price, thumbnail – user51361 May 29 '17 at 12:23
  • @AmritPalSingh : Text Box on CMS page, when customer enter the sku on text box they get name, price , thumbnail – user51361 May 29 '17 at 12:25
  • @MohitKumarArora : Actully simple text box on my cms page, when user enter the sku or products name, they get name, price, thumbnail – user51361 May 29 '17 at 12:26

You can do this with jQuery. On entering sku you can call the product collection and show the desired fields in HTML in that CMS page.

You can use this method to call product data:

$_product = Mage::getModel('catalog/product')->loadBySku($sku);

$_product->getName(); // display product name
  • How can i use your code on cms block – user51361 May 29 '17 at 12:31
  • its not wokring... – user51361 May 29 '17 at 12:34
  • 1
    For this you have to make a custom template .phtml and call it in your cms page. – Amrit Pal Singh May 29 '17 at 12:34
  • I am newbie, could you pls explain briefly. – user51361 May 29 '17 at 12:35
  • I have one Question. Do your CMS page have any other designs or html beside this text box ? – Amrit Pal Singh May 29 '17 at 12:36

1) Create a phtml in app/design/frontend/{package}/{theme}/template/cms/custom.phtml

2) Put this piece of code in your cms page:

{{ block type="core/template" name="custom.page" template="cms/custom.phtml"}}

3) Put your text box and what you want plus the code below in custom.phtml "Step 1)"

$sku = 10; //this sku you get it from your text box.
$_product = Mage::getModel('catalog/product')->getCollection()
                  ->addAttributeToSelect(array('name', 'sku', 'price', 'thumbnail'))
                  ->addAttributeToFilter('status', 1)
                  ->addAttributeToFilter('sku', array('in' => $sku));

$imageHelper = Mage::helper('catalog/image');
foreach($_product as $prod){
    $name      = $prod->getName();
    $price     = $prod->getPrice();
    $thumbnail = $imageHelper->init($prod, 'thumbnail')->resize(150,220);
  echo $name;<br/>

  echo $price;<br/>

  echo $thumbnail;
  • 1
    Thanks for this answer - just to add to it for others, you could make it more reusable by passing the SKU as a parameter ie {{ block type="core/template" custom_sku="10" name="custom.page" template="cms/custom.phtml"}} and retrieve it in the template $sku = $this->getData('custom_sku'); instead of hardcoding it. – McNab Feb 13 '18 at 14:37