protected function _toHtml() { if ($this->_isEnabled && $this->getColorSwatch()->getColorSwatchCollection() == null) { return $this->getColorSwatch()->getData('swatch_error'); } return Mage::getStoreConfig('smdesign_colorswatch/general/enabled_colorswatch') ? parent::_toHtml() : ''; }
protected function _toHtml() { $html = parent::_toHtml(); if ('product.info.options.configurable' == $this->getNameInLayout()) { $html = str_replace('super-attribute-select', 'no-display super-attribute-select', $html); $_product = $this->getProduct(); $_useSimplePrice = Mage::helper('amconf')->getConfigUseSimplePrice() == 2 || (Mage::helper('amconf')->getConfigUseSimplePrice() == 1 and $_product->getData('amconf_simple_price')) ? true : false; $id = $_product->getEntityId(); $imageSizeAtCategoryPageX = Mage::getStoreConfig('amconf/list/main_image_list_size_x'); $imageSizeAtCategoryPageY = Mage::getStoreConfig('amconf/list/main_image_list_size_y'); $parentImage = (string) $this->helper('catalog/image')->init($_product, 'small_image')->resize($imageSizeAtCategoryPageX, $imageSizeAtCategoryPageY); $productUrl = $_product->getProductUrl(); $productUrl = substr($productUrl, strrpos($productUrl, "/")); $confData = array('textNotAvailable' => $this->__('Choose previous option please...'), 'useSimplePrice' => intval($_useSimplePrice), 'url' => $productUrl, 'onclick' => Mage::helper('checkout/cart')->getAddUrl($_product)); $simpleProducts = $this->getProduct()->getTypeInstance(true)->getUsedProducts(null, $_product); if ($this->_currentAttributes) { $this->_currentAttributes = array_unique($this->_currentAttributes); foreach ($simpleProducts as $simple) { /* @var $simple Mage_Catalog_Model_Product */ $key = array(); foreach ($this->_currentAttributes as $attributeCode) { $key[] = $simple->getData($attributeCode); } if ($key) { $strKey = implode(',', $key); $confData[$strKey] = array(); if (!('no_selection' == $simple->getSmallImage() || '' == $simple->getSmallImage())) { $confData[$strKey]['small_image'] = (string) $this->helper('catalog/image')->init($simple, 'small_image')->resize($imageSizeAtCategoryPageX, $imageSizeAtCategoryPageY); $confData[$strKey]['parent_image'] = $parentImage; if (Mage::getStoreConfig('amconf/general/oneselect_reload')) { $k = $strKey; if (strpos($strKey, ',') > 0) { $k = substr($strKey, 0, strpos($strKey, ',')); } if (!(array_key_exists($k, $confData) && array_key_exists('small_image', $confData[$k]))) { $confData[$k]['small_image'] = $confData[$strKey]['small_image']; $confData[$k]['parent_image'] = $confData[$strKey]['parent_image']; } } else { //for only first } } else { $confData[$strKey]['small_image'] = $parentImage; $confData[$strKey]['parent_image'] = $parentImage; } $confData[$strKey]['not_is_in_stock'] = !$simple->isSaleable(); // the html blocks are required for product view page if ($_useSimplePrice) { $tierPriceHtml = $this->getTierPriceHtml($simple); $confData[$strKey]['price_html'] = $this->getPriceHtml($simple) . $tierPriceHtml; } //for >3 if (Mage::getStoreConfig('amconf/general/oneselect_reload')) { $pos = strpos($strKey, ","); if ($pos) { $pos = strpos($strKey, ",", $pos + 1); if ($pos) { $newKey = substr($strKey, 0, $pos); $confData[$newKey] = $confData[$strKey]; } } } } } $html = '<script type="text/javascript"> confData[' . $id . '] = new AmConfigurableData(' . Zend_Json::encode($confData) . '); amRequaredField = "' . $this->__('↑ This is a required field.') . '"; </script>' . $html; } } return $html; }