Thursday , November 15 2018
Home >> All tutorial >> Display Items Custom Option On Product Listing Page

Display Items Custom Option On Product Listing Page

Have you ever been struggled with showing custom options of products in Magento? Of course there are plenty of extensions on the market providing this function, but why spending time on researching and comparing when you could do it yourself with a little twist. This post actually is a short tutorial to guide you how to archive this task on the product listing page. Just simply copy and paste code below into your list.phtml file:

  1. <?php $productSku = $_product->getSku();
  2.            $product = Mage::getModel(‘catalog/product’);
  3.             $productId = $product->getIdBySku( $productSku );
  4.             $product = Mage::getModel(“catalog/product”)->load($productId);
  5.             $attVal = $product->getOptions();
  6.             $optStr = “”;
  7.         foreach($attVal as $optionKey => $optionVal) {
  8.         $optStr .= $optionVal->getTitle().“: “;
  9.         $optStr .= “<select style=’display:block; clear:both;’ name=’options[“.$optionVal->getId().“]’>”;
  10.         foreach($optionVal->getValues() as $valuesKey => $valuesVal) {
  11.         $optStr .= “<option value='”.$valuesVal->getId().“‘>”.$valuesVal->getTitle().“</option>”;
  12.             }
  13.  
  14.     $optStr .= “</select>”;
  15.             }
  16.         echo($optStr );
  17.           ?> 

Hope you find it’s helpful! If you have other idea, please share with us here. All comments are welcome 🙂

Source: http://abhaykhatariya.blogspot.in/

Here is the library of Magento Download for FREE (all versions)

Your Magento website needs a powerful Magento ERP for stock control.

DON'T MISS THE CHANCE!

magento erp

About Champ

Leave a Reply

Your email address will not be published. Required fields are marked *

Heap | Mobile and Web Analytics