Advertisement
andhiirawan

Magento : Product Detail Page : Colorswicher - JSHead

Oct 1st, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.03 KB | None | 0 0
  1. <!--app\design\frontend\theme\default\template\colorswicher\page\html\jshead.phtml-->
  2.  
  3. <?php
  4.  $_product = Mage::registry('current_product');
  5. ?>
  6. <script type="text/javascript">
  7. //<![CDATA[
  8.         var assocIMG =  // Added  - Removed { here, causes issues with other scripts when not working with a configurable product.
  9.         <?php
  10.         $dados = array();
  11.         if ($_product->getTypeId() == "configurable") {
  12.             echo "{";
  13.             $associated_products = $_product->loadByAttribute('sku', $_product->getSku())->getTypeInstance()->getUsedProducts();
  14.             foreach ($associated_products as $assoc)
  15.                 $dados[] = $assoc->getId().":'".($assoc->image == "no_selection" || $assoc->image == "" ? $this->helper('catalog/image')->init($_product, 'image', $_product->image)->resize(338) : $this->helper('catalog/image')->init($assoc, 'image', $assoc->image)->resize(338))."'";
  16.         } else {
  17.             $dados[] =  "''";
  18.         }
  19.         echo implode(',', $dados );    
  20.         if ($_product->getTypeId() == "configurable") {
  21.             echo "}";
  22.         }
  23.         ?> ;
  24.         var assocBIGIMG =  // Added  - Removed { here, causes issues with other scripts when not working with a configurable product.
  25.         <?php
  26.         $dados = array();
  27.         if ($_product->getTypeId() == "configurable") {
  28.             echo "{";
  29.             $associated_products = $_product->loadByAttribute('sku', $_product->getSku())->getTypeInstance()->getUsedProducts();
  30.             foreach ($associated_products as $assoc)
  31.                 $dados[] = $assoc->getId().":'".($assoc->image == "no_selection" || $assoc->image == "" ? $this->helper('catalog/image')->init($_product, 'image', $_product->image)->resize(1000) : $this->helper('catalog/image')->init($assoc, 'image', $assoc->image)->resize(1000))."'";
  32.         } else {
  33.             $dados[] =  "''";
  34.         }
  35.         echo implode(',', $dados );    
  36.         if ($_product->getTypeId() == "configurable") {
  37.             echo "}";
  38.         }
  39.         ?> ;
  40. //]]    
  41. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement