Example #1
0
 public function testGetJsonConfig()
 {
     $config = (array) json_decode($this->_block->getJsonConfig());
     $this->assertNotEmpty($config);
     $this->assertArrayHasKey('attributes', $config);
     $this->assertArrayHasKey('template', $config);
     $this->assertArrayHasKey('basePrice', $config);
     $this->assertArrayHasKey('productId', $config);
     $this->assertEquals(1, $config['productId']);
 }
 /**
  * Return current template
  * @return string
  */
 public function getTemplate()
 {
     if (parent::getTemplate()) {
         return parent::getTemplate();
     }
     return $this->getSubscription()->getTemplate();
 }
Example #3
0
 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() : '';
 }
 public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '')
 {
     $r4qEnabled = Mage::helper('itwebcommon')->getAttributeCodeForId($product->getId(), 'r4q_enabled');
     if ($r4qEnabled && Mage::helper('request4quote')->isPriceHidden($product)) {
         return '';
     }
     return parent::getPriceHtml($product, $displayMinimalPrice, $idSuffix);
 }
 /**
  * Returns additional values for js config, con be overriden by descedants
  *
  * @return array
  */
 protected function _getAdditionalConfig()
 {
     $result = parent::_getAdditionalConfig();
     $result['disablePriceReload'] = true;
     // There's no field for price at popup
     $result['stablePrices'] = true;
     // We don't want to recalc prices displayed in OPTIONs of SELECT
     return $result;
 }
Example #6
0
 protected function _construct()
 {
     parent::_construct();
     if (isset($attributes['template']) && $attributes['template']) {
         $this->setTemplate($attributes['template']);
     } elseif ($this->hasData("template")) {
         $this->setTemplate($this->getData('template'));
     } else {
         $template = 'venustheme/tempcp/cartedit/checkout/cart/item/edit/configurable.phtml';
         $this->setTemplate($template);
     }
 }
 /**
  * Composes configuration for js
  * overridden to support Out Of Stock labels
  * @return string
  */
 public function getJsonConfig()
 {
     $configEncoded = parent::getJsonConfig();
     $config = Mage::helper('core')->jsonDecode($configEncoded);
     $unSaleable = array();
     foreach ($this->getAllowProducts() as $product) {
         if (!$product->isSaleable()) {
             $unSaleable[] = $product->getId();
         }
     }
     $config['unsaleable'] = $unSaleable;
     $config = Mage::helper('core')->jsonEncode($config);
     return $config;
 }
Example #8
0
 public function getJsonConfig()
 {
     $config = parent::getJsonConfig();
     $config = Mage::helper('core')->jsonDecode($config);
     $attributes = $config['attributes'];
     foreach ($this->getAllowAttributes() as $attribute) {
         $productAttribute = $attribute->getProductAttribute();
         $attributeId = $productAttribute->getId();
         $theCount = count($attributes[$attributeId]['options']);
         if (isset($attributes[$attributeId])) {
             $attributes[$attributeId]['preselect'] = $theCount > 1 ? $attribute->getPreselect() : 'one';
         }
     }
     $config['attributes'] = $attributes;
     return Mage::helper('core')->jsonEncode($config);
 }
 public function getJsonConfig()
 {
     $jsonConfig = parent::getJsonConfig();
     $config = Zend_Json::decode($jsonConfig);
     if (Mage::helper('swatches')->getOptionsImageSize()) {
         $config['size'] = Mage::helper('swatches')->getOptionsImageSize();
     }
     foreach ($config['attributes'] as $attributeId => $attribute) {
         $attr = Mage::getModel('bluecom_swatches/attribute')->load($attributeId, 'attribute_id');
         if ($attr->getUseSwatches()) {
             foreach ($attribute['options'] as $i => $option) {
                 $this->_optionProducts[$attributeId][$option['id']] = $option['products'];
                 $config['attributes'][$attributeId]['use_swatches'] = 1;
                 $config['attributes'][$attributeId]['options'][$i]['image'] = Mage::helper('swatches')->getSwatchesBasedOnPriority($option['id'], $this->getProduct()->getEntityId());
             }
         }
     }
     $this->_jsonConfig = $config;
     return Zend_Json::encode($config);
 }
Example #10
0
 public function getJsonConfig()
 {
     $config = parent::getJsonConfig();
     $config = Mage::helper('core')->jsonDecode($config);
     $childProducts = array();
     foreach ($this->getAllowProducts() as $product) {
         $info = Mage::helper('customstockstatus')->getTheGoods($product->getId(), $product->getData());
         $alert_link = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'productalert/add/stock/product_id/' . $product->getId() . '/' . Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED . '/' . Mage::helper('core')->urlEncode($this->getProductUrl($product));
         $childProducts[$product->getId()]["stockstatus"] = $this->__('Availability:') . ' ' . Mage::helper('customstockstatus')->getAvailabilityText($info, 'simple');
         $childProducts[$product->getId()]["configstockstatus"] = Mage::helper('customstockstatus')->getConfigurableStockStatus($info);
         $childProducts[$product->getId()]["shipsby"] = $info['qty'] <= 0 || $info['isInStock'] == 0 ? '' : Mage::helper('customstockstatus')->getShipDateHtml($info, 'simple');
         $childProducts[$product->getId()]["alert"] = Mage::getStoreConfig('custom_stock/configurableproducts/alerts', Mage::app()->getStore()->getId()) && $info['isInStock'] == 0 ? $alert_link : '';
     }
     $mainInfo = Mage::helper('customstockstatus')->getTheGoods($this->getProduct()->getId(), $this->getProduct()->getData());
     $config['childProducts'] = $childProducts;
     $config['mainstock'] = $this->__('Availability:') . ' ' . Mage::helper('customstockstatus')->getAvailabilityText($mainInfo, 'configurable');
     $config['mainship'] = Mage::helper('customstockstatus')->getShipDateHtml($mainInfo, 'configurable');
     $config['dynamics'] = Mage::getStoreConfig('custom_stock/configurableproducts/dynamics', Mage::app()->getStore()->getId());
     $config['showbottom'] = Mage::getStoreConfig('custom_stock/configurableproducts/bottomavail', Mage::app()->getStore()->getId());
     $config['showship'] = Mage::getStoreConfig('custom_stock/configurableproducts/configurableshowshipdate', Mage::app()->getStore()->getId()) && $mainInfo['ishidden'] == 0 ? "1" : "0";
     return Mage::helper('core')->jsonEncode($config);
 }
 public function getJsonConfig()
 {
     $config = Zend_Json::decode(parent::getJsonConfig());
     //childProducts is an array of productID => price.
     $childProducts = array();
     $childProductTierPriceHtml = array();
     $childBlock = $this->getLayout()->createBlock('catalog/product_view');
     //Create the extra price and tier price data/html we need.
     foreach ($this->getAllowProducts() as $product) {
         $productId = $product->getId();
         $childProducts[$productId] = $this->_registerJsPrice($this->_convertPrice($product->getFinalPrice()));
         if (count($childBlock->getTierPrices($product))) {
             $childProductTierPriceHtml[$productId] = $childBlock->getTierPriceHtml($product);
         }
     }
     //Remove any existing option prices.
     //Removing holes out of existing arrays is not nice,
     //but it keeps the extension's code separate so if Varien's getJsonConfig
     //is added to, things should still work.
     if (is_array($config['attributes'])) {
         foreach ($config['attributes'] as $attributeID => &$info) {
             if (is_array($info['options'])) {
                 foreach ($info['options'] as &$option) {
                     unset($option['price']);
                 }
                 unset($option);
                 //clear foreach var ref
             }
         }
         unset($info);
         //clear foreach var ref
     }
     $config['childProducts'] = $childProducts;
     $config['priceFromLabel'] = $this->__('Price From:');
     $config['childProductTierPriceHtml'] = $childProductTierPriceHtml;
     $config['ajaxBaseUrl'] = Mage::getUrl('oi/ajax/');
     //Mage::log($config);
     return Zend_Json::encode($config);
 }
Example #12
0
 public function getJsonConfig()
 {
     $jsonConfig = parent::getJsonConfig();
     $config = Zend_Json::decode($jsonConfig);
     $swatchesIds = array();
     if (Mage::getStoreConfig('swatches/default/show_swatches')) {
         foreach ($config['attributes'] as $attributeId => $attribute) {
             $attrSwatches = Mage::getModel('bluecom_swatches/attribute')->load($attributeId, 'attribute_id');
             if ($attrSwatches->getUseSwatches()) {
                 $config['attributes'][$attributeId]['swatches_size'] = Mage::helper('swatches')->getOptionsImageSizePDP();
                 $config['attributes'][$attributeId]['use_swatches'] = 1;
                 $swatchesIds[] = $attributeId;
                 foreach ($attribute['options'] as $i => $option) {
                     $this->childProducts[$attributeId][$option['id']] = $option['products'];
                     $config['attributes'][$attributeId]['options'][$i]['image'] = Mage::helper('swatches')->getSwatchesBasedOnPriority($option['id'], $this->getProduct()->getEntityId());
                 }
             }
         }
         Mage::unregister('swatches_allowed_ids');
         Mage::register('swatches_allowed_ids', $swatchesIds, true);
     }
     return Zend_Json::encode($config);
 }
 public function _prepareLayout()
 {
     return parent::_prepareLayout();
 }
Example #14
0
 public function isSalable($product = null)
 {
     $salable = parent::isSalable($product);
     if ($salable !== false) {
         $salable = false;
         if (!is_null($product)) {
             $this->setStoreFilter($product->getStoreId(), $product);
         }
         if (!Mage::app()->getStore()->isAdmin() && $product) {
             $collection = $this->getUsedProductCollection($product)->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setPageSize(1);
             if ($collection->getFirstItem()->getId()) {
                 $salable = true;
             }
         } else {
             foreach ($this->getUsedProducts(null, $product) as $child) {
                 if ($child->isSalable()) {
                     $salable = true;
                     break;
                 }
             }
         }
     }
     return $salable;
 }
 public function getJsonConfig()
 {
     $config = Zend_Json::decode(parent::getJsonConfig());
     $childProducts = array();
     //Create the extra price and tier price data/html we need.
     foreach ($this->getAllowProducts() as $product) {
         $productId = $product->getId();
         $childProducts[$productId] = array("price" => $this->_registerJsPrice($this->_convertPrice($product->getPrice())), "finalPrice" => $this->_registerJsPrice($this->_convertPrice($product->getFinalPrice())));
         if (Mage::getStoreConfig('SCP_options/product_page/change_name')) {
             $childProducts[$productId]["productName"] = $product->getName();
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_description')) {
             $childProducts[$productId]["description"] = $this->helper('catalog/output')->productAttribute($product, $product->getDescription(), 'description');
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_short_description')) {
             $childProducts[$productId]["shortDescription"] = $this->helper('catalog/output')->productAttribute($product, nl2br($product->getShortDescription()), 'short_description');
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_attributes')) {
             $childBlock = $this->getLayout()->createBlock('catalog/product_view_attributes');
             $childProducts[$productId]["productAttributes"] = $childBlock->setTemplate('catalog/product/view/attributes.phtml')->setProduct($product)->toHtml();
         }
         #if image changing is enabled..
         if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
             #but dont bother if fancy image changing is enabled
             if (!Mage::getStoreConfig('SCP_options/product_page/change_image_fancy')) {
                 #If image is not placeholder...
                 if ($product->getImage() !== 'no_selection') {
                     $childProducts[$productId]["imageUrl"] = (string) Mage::helper('catalog/image')->init($product, 'image');
                 }
             }
         }
     }
     //Remove any existing option prices.
     //Removing holes out of existing arrays is not nice,
     //but it keeps the extension's code separate so if Varien's getJsonConfig
     //is added to, things should still work.
     if (is_array($config['attributes'])) {
         foreach ($config['attributes'] as $attributeID => &$info) {
             if (is_array($info['options'])) {
                 foreach ($info['options'] as &$option) {
                     unset($option['price']);
                 }
                 unset($option);
                 //clear foreach var ref
             }
         }
         unset($info);
         //clear foreach var ref
     }
     $p = $this->getProduct();
     $config['childProducts'] = $childProducts;
     if ($p->getMaxPossibleFinalPrice() != $p->getFinalPrice()) {
         $config['priceFromLabel'] = $this->__('Price From:');
     } else {
         $config['priceFromLabel'] = $this->__('');
     }
     $config['ajaxBaseUrl'] = Mage::getUrl('oi/ajax/');
     $config['productName'] = $p->getName();
     $config['description'] = $this->helper('catalog/output')->productAttribute($p, $p->getDescription(), 'description');
     $config['shortDescription'] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getShortDescription()), 'short_description');
     if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
         $config["imageUrl"] = (string) Mage::helper('catalog/image')->init($p, 'image');
     }
     $childBlock = $this->getLayout()->createBlock('catalog/product_view_attributes');
     $config["productAttributes"] = $childBlock->setTemplate('catalog/product/view/attributes.phtml')->setProduct($this->getProduct())->toHtml();
     if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
         if (Mage::getStoreConfig('SCP_options/product_page/change_image_fancy')) {
             $childBlock = $this->getLayout()->createBlock('catalog/product_view_media');
             $config["imageZoomer"] = $childBlock->setTemplate('catalog/product/view/media.phtml')->setProduct($this->getProduct())->toHtml();
         }
     }
     if (Mage::getStoreConfig('SCP_options/product_page/show_price_ranges_in_options')) {
         $config['showPriceRangesInOptions'] = true;
         $config['rangeToLabel'] = $this->__('to');
     }
     return Zend_Json::encode($config);
     //parent getJsonConfig uses the following instead, but it seems to just break inline translate of this json?
     //return Mage::helper('core')->jsonEncode($config);
 }
 public function getJsonConfig()
 {
     $config = Mage::helper('core')->jsonDecode(parent::getJsonConfig());
     $this->attachChildProducts($config);
     $config['template'] = str_replace('%s', '#{price}', $this->getCurrencyOutputFormat());
     $config['productStock'] = array();
     foreach ($this->getAllowProducts() as $simple) {
         $config['productStock'][$simple->getId()] = $simple->isSaleable() ? $simple->getStockItem()->getQty() : 0;
     }
     $i = 1;
     foreach ($this->getAllowAttributes() as $cfgAttr) {
         $_aId = $cfgAttr->getAttributeId();
         if (!isset($config['attributes'][$_aId])) {
             continue;
         }
         $config['attributes'][$_aId]['idx'] = $i++;
         $config['attributes'][$_aId]['identifyImage'] = $cfgAttr->getData('identify_image');
         $_sk = sprintf('super_attribute/%s/%s', $this->getProduct()->getId(), $cfgAttr->getAttributeId());
         $_pAttr = $cfgAttr->getProductAttribute();
         $config['perAttrChooseText'][$_aId] = Mage::helper('udprod')->__('- Select %s -', $_pAttr->getFrontend()->getLabel());
         $_swatchMap = $_pAttr->getSwatchMap();
         if (!is_array($_swatchMap)) {
             $_swatchMap = (array) Mage::helper('core')->jsonDecode($_swatchMap);
         }
         if (!empty($config['attributes'][$_aId]['options'])) {
             foreach ($config['attributes'][$_aId]['options'] as &$opt) {
                 if (isset($_swatchMap[$opt['id']])) {
                     $opt['swatch'] = sprintf('%s/catalog/swatch/%s/%s', Mage::getBaseUrl('media'), $_aId, $_swatchMap[$opt['id']]);
                 } else {
                     $opt['swatch'] = Mage::getDesign()->getSkinUrl('images/fpo/ph_swatch.gif');
                 }
             }
             unset($opt);
             if ($config['attributes'][$_aId]['idx'] == 1) {
                 $newOptions = array();
                 $usedValues = array();
                 $simpleProducts = $this->getAllowProducts();
                 foreach ($simpleProducts as $simpleProd) {
                     $usedValues[] = $simpleProd->getData($_pAttr->getAttributeCode());
                 }
                 $usedValues = array_unique($usedValues);
                 $defColor = $this->getDefaultColorByImage();
                 foreach ($config['attributes'][$_aId]['options'] as $opt) {
                     foreach ($usedValues as $usedValue) {
                         if ($opt['id'] == $usedValue) {
                             if ($defColor == $opt['id']) {
                                 array_unshift($newOptions, $opt);
                             } else {
                                 $newOptions[] = $opt;
                             }
                         }
                     }
                 }
                 $config['attributes'][$_aId]['options'] = $newOptions;
             }
         }
         if ($this->_getSession()->getData($_sk)) {
             $config['attributes'][$_aId]['defaultValueId'] = $this->_getSession()->getData($_sk);
             $config['attributes'][$_aId]['isColor'] = $_pAttr->getAttributeCode() == 'color';
         }
     }
     $this->_getSession()->unsetData('super_attribute');
     return Mage::helper('core')->jsonEncode($config);
 }
 public function getJsonConfig()
 {
     $config = Zend_Json::decode(parent::getJsonConfig());
     $childProducts = array();
     //Create the extra price and tier price data/html we need.
     $upsellbuffer = array();
     foreach ($this->getAllowProducts() as $product) {
         $productId = $product->getId();
         $childProducts[$productId] = array("price" => $this->_registerJsPrice($this->_convertPrice($product->getPrice())), "finalPrice" => $this->_registerJsPrice($this->_convertPrice($product->getFinalPrice())), "sku" => $product->getSku());
         if (Mage::getStoreConfig('SCP_options/product_page/change_name')) {
             $childProducts[$productId]["productName"] = $product->getName();
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_description')) {
             $childProducts[$productId]["description"] = $this->helper('catalog/output')->productAttribute($product, $product->getDescription(), 'description');
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_short_description')) {
             $childProducts[$productId]["shortDescription"] = $this->helper('catalog/output')->productAttribute($product, nl2br($product->getShortDescription()), 'short_description');
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_attributes')) {
             $childBlock = $this->getLayout()->createBlock('catalog/product_view_attributes');
             $childProducts[$productId]["productAttributes"] = $childBlock->setTemplate('catalog/product/view/attributes.phtml')->setProduct($product)->toHtml();
         }
         /* FG Modify BEGIN */
         $childProducts[$productId]["sellingpoints"] = $this->getLayout()->createBlock('catalog/product_view_attributes')->setTemplate('catalog/product/view/details.phtml')->setProduct($product)->toHtml();
         $childProducts[$productId]["number"] = $this->helper('catalog/output')->productAttribute($product, nl2br($product->getNumber()), 'number');
         $childProducts[$productId]["colorcode"] = $this->helper('catalog/output')->productAttribute($product, nl2br($product->getColorCode()), 'color_code');
         $childProducts[$productId]["iid"] = $this->helper('catalog/output')->productAttribute($product, nl2br($product->getIid()), 'iid');
         $childProducts[$productId]["ean"] = $this->helper('catalog/output')->productAttribute($product, nl2br($product->getEan()), 'ean');
         $childProducts[$productId]["careinsandmaterials"] = $this->getLayout()->createBlock('catalog/product_view_attributes')->setTemplate('catalog/product/view/materialcare.phtml')->setProduct($product)->toHtml();
         $childProducts[$productId]["badge"] = $this->getLayout()->createBlock('catalog/product_view_attributes')->setTemplate('catalog/product/view/description.phtml')->setProduct($product)->toHtml();
         $childProducts[$productId]["storefinder"] = $this->helper('catalog/output')->productAttribute($product, nl2br($product->getStorefinder()), 'storefinder');
         $childProducts[$productId]["stylee"] = $this->helper('catalog/output')->productAttribute($product, nl2br($product->getStyle()), 'style');
         /* FG Modify END */
         $bChangeStock = Mage::getStoreConfig('SCP_options/product_page/change_stock');
         if ($bChangeStock) {
             // Stock status HTML
             $oStockBlock = $this->getLayout()->createBlock('catalog/product_view_type_simple')->setTemplate('catalog/product/view/scpavailability.phtml');
             $childProducts[$productId]["stockStatus"] = $oStockBlock->setProduct($product)->toHtml();
             // Add to cart button
             $oAddToCartBlock = $this->getLayout()->createBlock('catalog/product_view_type_simple')->setTemplate('catalog/product/view/addtocart.phtml');
             $childProducts[$productId]["addToCart"] = $oAddToCartBlock->setProduct($product)->toHtml();
         }
         $bShowProductAlerts = Mage::getStoreConfig(Mage_ProductAlert_Model_Observer::XML_PATH_STOCK_ALLOW);
         if ($bShowProductAlerts && !$product->isAvailable()) {
             $oAlertBlock = $this->getLayout()->createBlock('productalert/product_view')->setTemplate('productalert/product/view.phtml')->setSignupUrl(Mage::helper('productalert')->setProduct($product)->getSaveUrl('stock'));
             $childProducts[$productId]["alertHtml"] = $oAlertBlock->toHtml();
         }
         #if image changing is enabled..
         if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
             #but dont bother if fancy image changing is enabled
             if (!Mage::getStoreConfig('SCP_options/product_page/change_image_fancy')) {
                 #If image is not placeholder...
                 if ($product->getImage() !== 'no_selection') {
                     $productMag = Mage::getModel('catalog/product')->load($productId);
                     foreach ($productMag->getMediaGalleryImages() as $image) {
                         $childProducts[$productId]["imageUrl"][] = (string) Mage::helper('catalog/image')->init($product, 'image', $image->getFile());
                     }
                 }
             }
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_upsell')) {
             /** @var Mage_Catalog_Block_Product_List_Upsell $childBlock */
             $childBlock = $this->getLayout()->getBlock('product.info.upsell');
             $oldProduct = $childBlock->getProduct();
             $childBlock->setProduct($product);
             $tmp = $childBlock->getData();
             $tmp["ColorCode"] = $product->getColorCode();
             if (!isset($upsellbuffer[$tmp["ColorCode"]])) {
                 // Add Parameter for Color_Code
                 $childBlock->setData($tmp);
                 $upsellbuffer[$tmp["ColorCode"]] = $childBlock->toHtml();
                 $childProducts[$productId]['upsell'] = $upsellbuffer[$tmp["ColorCode"]];
             } else {
                 $childProducts[$productId]['upsell'] = $upsellbuffer[$tmp["ColorCode"]];
             }
             $childBlock->setProduct($oldProduct);
         }
     }
     //Remove any existing option prices.
     //Removing holes out of existing arrays is not nice,
     //but it keeps the extension's code separate so if Varien's getJsonConfig
     //is added to, things should still work.
     if (is_array($config['attributes'])) {
         foreach ($config['attributes'] as $attributeID => &$info) {
             if (is_array($info['options'])) {
                 foreach ($info['options'] as &$option) {
                     unset($option['price']);
                 }
                 unset($option);
                 //clear foreach var ref
             }
         }
         unset($info);
         //clear foreach var ref
     }
     $p = $this->getProduct();
     $config['childProducts'] = $childProducts;
     if ($p->getMaxPossibleFinalPrice() != $p->getFinalPrice()) {
         $config['priceFromLabel'] = $this->__('Price From:');
     } else {
         $config['priceFromLabel'] = $this->__('');
     }
     $config['ajaxBaseUrl'] = Mage::getUrl('oi/ajax/');
     $config['productName'] = $p->getName();
     $config['description'] = $this->helper('catalog/output')->productAttribute($p, $p->getDescription(), 'description');
     $config['shortDescription'] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getShortDescription()), 'short_description');
     /* FG Modify BEGIN */
     $config['sellingpoints'] = $this->getLayout()->createBlock('catalog/product_view_attributes')->setTemplate('catalog/product/view/details.phtml')->setProduct($p)->toHtml();
     $config['number'] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getNumber()), 'number');
     $config['colorcode'] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getColorCode()), 'color_code');
     $config['iid'] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getIid()), 'iid');
     $config["ean"] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getEan()), 'ean');
     $config["careinsandmaterials"] = $this->getLayout()->createBlock('catalog/product_view_attributes')->setTemplate('catalog/product/view/materialcare.phtml')->setProduct($p)->toHtml();
     $config['badge'] = $this->getLayout()->createBlock('catalog/product_view_description')->setTemplate('catalog/product/view/description.phtml')->setProduct($p)->toHtml();
     $config['storefinder'] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getStorefinder()), 'storefinder');
     $config['stylee'] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getStyle()), 'style');
     /* FG Modify End */
     if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
         foreach ($p->getMediaGalleryImages() as $image) {
             $config["imageUrl"][] = (string) Mage::helper('catalog/image')->init($p, 'image', $image->getFile());
         }
     }
     $childBlock = $this->getLayout()->createBlock('catalog/product_view_attributes');
     $config["productAttributes"] = $childBlock->setTemplate('catalog/product/view/attributes.phtml')->setProduct($p)->toHtml();
     $bShowProductAlerts = Mage::getStoreConfig(Mage_ProductAlert_Model_Observer::XML_PATH_STOCK_ALLOW);
     if ($bShowProductAlerts && !Mage::registry('child_product')->isAvailable()) {
         $oAlertBlock = $this->getLayout()->createBlock('productalert/product_view')->setTemplate('productalert/product/view.phtml')->setSignupUrl(Mage::helper('productalert')->setProduct(Mage::registry('child_product'))->getSaveUrl('stock'));
         $config["alertHtml"] = $oAlertBlock->toHtml();
     }
     if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
         if (Mage::getStoreConfig('SCP_options/product_page/change_image_fancy')) {
             $childBlock = $this->getLayout()->createBlock('infortis_cloudzoom/product_view_media');
             $config["imageZoomer"] = $childBlock->setTemplate('infortis/cloudzoom/product/view/media.phtml')->setProduct($p)->toHtml();
         }
     }
     if (Mage::getStoreConfig('SCP_options/product_page/change_upsell')) {
         /** @var Mage_Catalog_Block_Product_List_Upsell $childBlock */
         $childBlock = $this->getLayout()->getBlock('product.info.upsell');
         $oldProduct = $childBlock->getProduct();
         $childBlock->setProduct($p);
         $config['upsell'] = $childBlock->toHtml();
         $childBlock->setProduct($oldProduct);
     }
     if (Mage::getStoreConfig('SCP_options/product_page/show_price_ranges_in_options')) {
         $config['showPriceRangesInOptions'] = true;
         $config['rangeToLabel'] = $this->__('to');
     }
     return Zend_Json::encode($config);
     //parent getJsonConfig uses the following instead, but it seems to just break inline translate of this json?
     //return Mage::helper('core')->jsonEncode($config);
 }
Example #18
0
 $pro[$i]["additional_data"] = $data;
 $pro[$i]["image_gallary"] = $imagegallary;
 $summaryData = Mage::getModel('review/review_summary')->setStoreId($storeId)->load($_product->getId());
 //		Zend_Debug::dump($summaryData);
 $pro[$i]["reviewCount"] = $summaryData->getReviewsCount();
 //$pro[$i]["reviewSummary"]  = round((int) $summaryData->getRatingSummary() / 10);
 $pro[$i]["reviewSummary"] = $summaryData->getRatingSummary();
 //$pro[$i]["ratings"]  = getRating($_product->getId());
 $pro[$i]["available"] = (int) $_product->isSalable();
 $pro[$i]["inStock"] = (int) $_product->getStockItem()->getIsInStock();
 $pro[$i]["hasOptions"] = (int) $_product->getHasOptions();
 $pro[$i]["shotDesc"] = $_product->getShortDescription();
 $pro[$i]["desc"] = $_product->getDescription();
 $EntityId = $_product->getEntityTypeId();
 if ($_product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
     $temp = new Mage_Catalog_Block_Product_View_Type_Configurable();
     $temp->setData('product', $product);
     //		        echo "<pre>";
     //		        print_r ($temp->getAllowAttributes());
     $_attributes = Mage::helper('core')->decorateArray($temp->getAllowAttributes());
     if ($_product->isSaleable() && count($_attributes)) {
         $z = 0;
         $attr = array();
         foreach ($_attributes as $_attribute) {
             $productAttrib = $_attribute->getProductAttribute();
             //echo "Product_id =".$product->getId()."==>".$_attribute->getLabel()."</br></br></br>";
             $attr[$z]["label"] = $productAttrib->getFrontendLabel();
             $attr[$z]["is_required"] = $productAttrib->getIsRequired();
             $attr[$z]["attribute_id"] = $productAttrib->getAttributeId();
             $attr[$z]["attribute_code"] = $productAttrib->getAttributeCode();
             $attr[$z]["entity_attribute_id"] = $productAttrib->getEntityAttributeId();
 public function getJsonConfig()
 {
     $config = Zend_Json::decode(parent::getJsonConfig());
     $childProducts = array();
     $p = $this->getProduct();
     //Create the extra price and tier price data/html we need.
     foreach ($this->getAllowProducts() as $product) {
         $productId = $product->getId();
         if ($p->getData('msrp')) {
             $msrpPrice = $p->getData('msrp');
         } elseif ($p->getData('msrp_factor')) {
             $msrpPrice = round($p->getData('msrp_factor') * $product->getPrice() / 10) * 10;
         } else {
             $msrpPrice = 0;
         }
         $childProducts[$productId] = array("price" => $this->_registerJsPrice($this->_convertPrice($product->getPrice())), "finalPrice" => $this->_registerJsPrice($this->_convertPrice($product->getFinalPrice())), "sku" => $product->getSku(), "msrp" => $this->_registerJsPrice($this->_convertPrice($msrpPrice)));
         if (Mage::getStoreConfig('SCP_options/product_page/change_name')) {
             $childProducts[$productId]["productName"] = $product->getName();
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_description')) {
             $childProducts[$productId]["description"] = $this->helper('catalog/output')->productAttribute($product, $product->getDescription(), 'description');
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_short_description')) {
             $childProducts[$productId]["shortDescription"] = $this->helper('catalog/output')->productAttribute($product, nl2br($product->getShortDescription()), 'short_description');
         }
         if (Mage::getStoreConfig('SCP_options/product_page/change_attributes')) {
             $childBlock = $this->getLayout()->createBlock('catalog/product_view_attributes');
             $childProducts[$productId]["productAttributes"] = $childBlock->setTemplate('catalog/product/view/attributes.phtml')->setProduct($product)->toHtml();
         }
         $bChangeStock = Mage::getStoreConfig('SCP_options/product_page/change_stock');
         if ($bChangeStock) {
             // Stock status HTML
             $oStockBlock = $this->getLayout()->createBlock('catalog/product_view_type_simple')->setTemplate('catalog/product/view/scpavailability.phtml');
             $childProducts[$productId]["stockStatus"] = $oStockBlock->setProduct($product)->toHtml();
             // Add to cart button
             $oAddToCartBlock = $this->getLayout()->createBlock('catalog/product_view_type_simple')->setTemplate('catalog/product/view/addtocart.phtml');
             $childProducts[$productId]["addToCart"] = $oAddToCartBlock->setProduct($product)->toHtml();
         }
         $bShowProductAlerts = Mage::getStoreConfig(Mage_ProductAlert_Model_Observer::XML_PATH_STOCK_ALLOW);
         if ($bShowProductAlerts && !$product->isAvailable()) {
             $oAlertBlock = $this->getLayout()->createBlock('productalert/product_view')->setTemplate('productalert/product/view.phtml')->setSignupUrl(Mage::helper('productalert')->setProduct($product)->getSaveUrl('stock'));
             $childProducts[$productId]["alertHtml"] = $oAlertBlock->toHtml();
         }
         #if image changing is enabled..
         if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
             #but dont bother if fancy image changing is enabled
             if (!Mage::getStoreConfig('SCP_options/product_page/change_image_fancy')) {
                 #If image is not placeholder...
                 if ($product->getImage() !== 'no_selection') {
                     $childProducts[$productId]["imageUrl"] = (string) Mage::helper('catalog/image')->init($product, 'image');
                 }
             }
         }
     }
     //Remove any existing option prices.
     //Removing holes out of existing arrays is not nice,
     //but it keeps the extension's code separate so if Varien's getJsonConfig
     //is added to, things should still work.
     if (is_array($config['attributes'])) {
         foreach ($config['attributes'] as $attributeID => &$info) {
             if (is_array($info['options'])) {
                 foreach ($info['options'] as &$option) {
                     unset($option['price']);
                 }
                 unset($option);
                 //clear foreach var ref
             }
         }
         unset($info);
         //clear foreach var ref
     }
     $p = $this->getProduct();
     $config['childProducts'] = $childProducts;
     if ($p->getMaxPossibleFinalPrice() != $p->getFinalPrice()) {
         $config['priceFromLabel'] = $this->__('Price From:');
     } else {
         $config['priceFromLabel'] = $this->__('');
     }
     $config['ajaxBaseUrl'] = Mage::getUrl('oi/ajax/');
     $config['productName'] = $p->getName();
     $config['description'] = $this->helper('catalog/output')->productAttribute($p, $p->getDescription(), 'description');
     $config['shortDescription'] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getShortDescription()), 'short_description');
     if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
         $config["imageUrl"] = (string) Mage::helper('catalog/image')->init($p, 'image');
     }
     $childBlock = $this->getLayout()->createBlock('catalog/product_view_attributes');
     $config["productAttributes"] = $childBlock->setTemplate('catalog/product/view/attributes.phtml')->setProduct($this->getProduct())->toHtml();
     $bShowProductAlerts = Mage::getStoreConfig(Mage_ProductAlert_Model_Observer::XML_PATH_STOCK_ALLOW);
     if ($bShowProductAlerts && !Mage::registry('child_product')->isAvailable()) {
         $oAlertBlock = $this->getLayout()->createBlock('productalert/product_view')->setTemplate('productalert/product/view.phtml')->setSignupUrl(Mage::helper('productalert')->setProduct(Mage::registry('child_product'))->getSaveUrl('stock'));
         $config["alertHtml"] = $oAlertBlock->toHtml();
     }
     if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
         if (Mage::getStoreConfig('SCP_options/product_page/change_image_fancy')) {
             $childBlock = $this->getLayout()->createBlock('catalog/product_view_media');
             $config["imageZoomer"] = $childBlock->setTemplate('catalog/product/view/media.phtml')->setProduct($this->getProduct())->toHtml();
         }
     }
     if (Mage::getStoreConfig('SCP_options/product_page/show_price_ranges_in_options')) {
         $config['showPriceRangesInOptions'] = true;
         $config['rangeToLabel'] = $this->__('to');
     }
     return Zend_Json::encode($config);
     //parent getJsonConfig uses the following instead, but it seems to just break inline translate of this json?
     //return Mage::helper('core')->jsonEncode($config);
 }
Example #20
0
 public function getJsonConfig()
 {
     $attributes = array();
     $options = array();
     //$optionsSaleable = array();
     $saleableProducts = array();
     $store = $this->getCurrentStore();
     $taxHelper = Mage::helper('tax');
     $currentProduct = $this->getProduct();
     $preconfiguredFlag = $currentProduct->hasPreconfiguredValues();
     if ($preconfiguredFlag) {
         $preconfiguredValues = $currentProduct->getPreconfiguredValues();
         $defaultValues = array();
     }
     /*$total_attributes =  count($this->getAllowAttributes());
       $_att_counter = 0;*/
     foreach ($this->getAllowProducts() as $product) {
         $productId = $product->getId();
         //$saleable = ;
         $saleableProducts[$productId] = $product->isSaleable();
         foreach ($this->getAllowAttributes() as $attribute) {
             $productAttribute = $attribute->getProductAttribute();
             $productAttributeId = $productAttribute->getId();
             $attributeValue = $product->getData($productAttribute->getAttributeCode());
             if (!isset($options[$productAttributeId])) {
                 $options[$productAttributeId] = array();
             }
             if (!isset($options[$productAttributeId][$attributeValue])) {
                 $options[$productAttributeId][$attributeValue] = array();
             }
             $options[$productAttributeId][$attributeValue][] = $productId;
             //$optionsSaleable[$productAttributeId][$attributeValue][] = array( "id"=> $productId, "saleable" => $saleable );
         }
     }
     $this->_resPrices = array($this->_preparePrice($currentProduct->getFinalPrice()));
     foreach ($this->getAllowAttributes() as $attribute) {
         $productAttribute = $attribute->getProductAttribute();
         $attributeId = $productAttribute->getId();
         $info = array('id' => $productAttribute->getId(), 'code' => $productAttribute->getAttributeCode(), 'label' => $attribute->getLabel(), 'options' => array());
         $optionPrices = array();
         $prices = $attribute->getPrices();
         if (is_array($prices)) {
             foreach ($prices as $value) {
                 if (!$this->_validateAttributeValue($attributeId, $value, $options)) {
                     continue;
                 }
                 $currentProduct->setConfigurablePrice($this->_preparePrice($value['pricing_value'], $value['is_percent']));
                 $currentProduct->setParentId(true);
                 Mage::dispatchEvent('catalog_product_type_configurable_price', array('product' => $currentProduct));
                 $configurablePrice = $currentProduct->getConfigurablePrice();
                 /*$_saleable = false;
                   foreach($optionsSaleable[$attributeId][$value['value_index']] as $sindex=>$svalue){
                       if($svalue["saleable"]) {
                           $_saleable = true;
                           //break;
                       }
                   }*/
                 if (isset($options[$attributeId][$value['value_index']])) {
                     $productsIndex = $options[$attributeId][$value['value_index']];
                 } else {
                     $productsIndex = array();
                 }
                 $info['options'][] = array('id' => $value['value_index'], 'label' => $value['label'], 'price' => $configurablePrice, 'oldPrice' => $this->_prepareOldPrice($value['pricing_value'], $value['is_percent']), 'products' => $productsIndex);
                 $optionPrices[] = $configurablePrice;
             }
         }
         /**
          * Prepare formated values for options choose
          */
         foreach ($optionPrices as $optionPrice) {
             foreach ($optionPrices as $additional) {
                 $this->_preparePrice(abs($additional - $optionPrice));
             }
         }
         if ($this->_validateAttributeInfo($info)) {
             $attributes[$attributeId] = $info;
         }
         // Add attribute default value (if set)
         if ($preconfiguredFlag) {
             $configValue = $preconfiguredValues->getData('super_attribute/' . $attributeId);
             if ($configValue) {
                 $defaultValues[$attributeId] = $configValue;
             }
         }
     }
     $taxCalculation = Mage::getSingleton('tax/calculation');
     if (!$taxCalculation->getCustomer() && Mage::registry('current_customer')) {
         $taxCalculation->setCustomer(Mage::registry('current_customer'));
     }
     $_request = $taxCalculation->getRateRequest(false, false, false);
     $_request->setProductClassId($currentProduct->getTaxClassId());
     $defaultTax = $taxCalculation->getRate($_request);
     $_request = $taxCalculation->getRateRequest();
     $_request->setProductClassId($currentProduct->getTaxClassId());
     $currentTax = $taxCalculation->getRate($_request);
     $taxConfig = array('includeTax' => $taxHelper->priceIncludesTax(), 'showIncludeTax' => $taxHelper->displayPriceIncludingTax(), 'showBothPrices' => $taxHelper->displayBothPrices(), 'defaultTax' => $defaultTax, 'currentTax' => $currentTax, 'inclTaxTitle' => Mage::helper('catalog')->__('Incl. Tax'));
     $config = array('attributes' => $attributes, 'template' => str_replace('%s', '#{price}', $store->getCurrentCurrency()->getOutputFormat()), 'basePrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getFinalPrice())), 'oldPrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getPrice())), 'productId' => $currentProduct->getId(), 'chooseText' => Mage::helper('catalog')->__('Choose an Option...'), 'taxConfig' => $taxConfig, 'saleableProducts' => $saleableProducts);
     if ($preconfiguredFlag && !empty($defaultValues)) {
         $config['defaultValues'] = $defaultValues;
     } elseif (Mage::getStoreConfig("attributeswatches/settings/defaultselect")) {
         /* set default for first attribute 
          * if setting is yes 
          * and default values (cart/buyrequest) is empty */
         /* get first attribute and first value */
         foreach ($attributes as $_default_attibute_id => $_attribute_info) {
             foreach ($_attribute_info['options'] as $_option_index => $_option_info) {
                 $defaultValues[$_default_attibute_id] = $_option_info['id'];
                 break;
             }
             break;
         }
         $config['defaultValues'] = $defaultValues;
     }
     $config = array_merge($config, $this->_getAdditionalConfig());
     return Mage::helper('core')->jsonEncode($config);
     return parent::getJsonConfig();
     $_info = json_decode(parent::getJsonConfig(), true);
     /* will get all the attributes with swatches  */
     $_attributes_with_swatches = Mage::helper("attributeswatches")->getAttributesWithSwatchesProductView();
     $_attributes_hideselect = Mage::helper("attributeswatches")->getAttributesProductViewHideSelect();
     $_attributes_switchgallery = Mage::helper("attributeswatches")->getAttributesSwitchGalleryProductView();
     /* hide select only if the attribute has another type of selector associated */
     foreach ($_attributes_hideselect as $_id => $type) {
         if (!isset($_attributes_with_swatches[$_id])) {
             unset($_attributes_hideselect[$_id]);
         }
     }
     $_swatches_ids = array();
     foreach ($_info['attributes'] as $_id => $_attribute) {
         /* options with swatches from the db */
         if (isset($_attributes_with_swatches[$_attribute["code"]]) && $_attributes_with_swatches[$_attribute["code"]] == "image") {
             foreach ($_attribute["options"] as $_option) {
                 $_swatches_ids[] = $_option["id"];
             }
         }
         /* set the swatch type to display in frontend */
         if (isset($_attributes_with_swatches[$_attribute["code"]])) {
             $_info['attributes'][$_id]["swatch_type"] = $_attributes_with_swatches[$_attribute["code"]];
         } else {
             $_info['attributes'][$_id]["swatch_type"] = false;
         }
         /* hide/show select in frontend */
         $_info['attributes'][$_id]["hideselect"] = isset($_attributes_hideselect[$_attribute["code"]]);
         /* switch gallery when attribute is selected */
         $_info['attributes'][$_id]["switchgallery"] = isset($_attributes_switchgallery[$_attribute["code"]]);
     }
     $_options = Mage::getModel('attributeswatches/attributeswatches')->getCollection()->addFieldToFilter('main_table.option_id', array('in' => $_swatches_ids));
     $_swatches_values = array();
     foreach ($_options as $_option) {
         $_swatch = "";
         if ($_option->getMode() == 2) {
             $_swatch = "background-color:#" . $_option->getColor();
         } elseif ($_option->getMode() == 1) {
             $_swatch = "background-image:url('" . Mage::getBaseUrl('media') . 'attributeswatches/' . $_option->getFilename() . "');";
         }
         $_swatches_values[$_option->getOptionId()] = $_swatch;
     }
     /* assign the images or colors to the swatches */
     foreach ($_info['attributes'] as $_id => $_attribute) {
         if (isset($_attributes_with_swatches[$_attribute["code"]]) && $_attributes_with_swatches[$_attribute["code"]] == "image") {
             foreach ($_attribute["options"] as $_i => $_option) {
                 if (isset($_swatches_values[$_option["id"]])) {
                     $_info['attributes'][$_id]["options"][$_i]["swatch_value"] = $_swatches_values[$_option["id"]];
                 }
             }
         }
     }
     return $_info;
 }
    public function swatchesHtmlAction()
    {
        $obj = new Mage_Catalog_Block_Product_View_Type_Configurable();
        $_smpproductId = 0;
        $_product_id = Mage::app()->getRequest()->getParam('product');
        $_product = Mage::getModel('catalog/product')->load($_product_id);
        if (Mage::getStoreConfig('progallery/resizeImage/main_image_resize_width')) {
            $main_image_resize_width = Mage::getStoreConfig('progallery/resizeImage/main_image_resize_width');
        } else {
            $main_image_resize_width = 395;
        }
        if (Mage::getStoreConfig('progallery/resizeImage/main_image_resize_height')) {
            $main_image_resize_height = Mage::getStoreConfig('progallery/resizeImage/main_image_resize_height');
        } else {
            $main_image_resize_height = 413;
        }
        if (Mage::getStoreConfig('progallery/resizeImage/lightbox_image_resize_width')) {
            $lightbox_image_resize_width = Mage::getStoreConfig('progallery/resizeImage/lightbox_image_resize_width');
        } else {
            $lightbox_image_resize_width = 1100;
        }
        if (Mage::getStoreConfig('progallery/resizeImage/lightbox_image_resize_height')) {
            $lightbox_image_resize_height = Mage::getStoreConfig('progallery/resizeImage/lightbox_image_resize_height');
        } else {
            $lightbox_image_resize_height = 1150;
        }
        $confProd = Mage::getModel('catalog/product_type_configurable');
        // Get all attributes of configurable product
        $confAtts = $confProd->getConfigurableAttributesAsArray($_product);
        $isColorAvailable = false;
        $isSizeAvailable = false;
        $confCategory = Mage::getModel('catalog/category');
        $returnArray = $confCategory->getSwatchColorSizeDataArray($confAtts);
        $color = $returnArray['color'];
        //$colorData = $returnArray['colorData'];
        $colorDataRootPath = $returnArray['colorDataRootPath'];
        $superAtt = $returnArray['superAtt'];
        $size = $returnArray['size'];
        $sortedSize = $returnArray['sortedSize'];
        $sortedSizeAbbr = $returnArray['sortedSizeAbbr'];
        $isColorAvailable = $returnArray['isColorAvailable'];
        $isSizeAvailable = $returnArray['isSizeAvailable'];
        // get all associated product ids
        $childIds = $confProd->getUsedProductIds($_product);
        $price = $_product->getPrice();
        $finalPrice = $_product->getFinalPrice();
        $priceDiff = 0;
        if ($finalPrice != $price) {
            $priceDiff = $price - $finalPrice;
        }
        $optData = $confCategory->getSwatchOptData($childIds, $size, $priceDiff);
        foreach ($color['color'] as $ck => $cv) {
            foreach ($sortedSize as $sk => $sv) {
                if (!isset($optData[$ck][$sk])) {
                    $sortedOptData[$ck][$sk]['image'] = 0;
                    $sortedOptData[$ck][$sk]['small_image'] = 0;
                    $sortedOptData[$ck][$sk]['size_label'] = $sv;
                    $sortedOptData[$ck][$sk]['stock'] = 0;
                } else {
                    $sortedOptData[$ck][$sk] = $optData[$ck][$sk];
                }
            }
        }
        $swatchHtml = '';
        $cats = $_product->getCategoryIds();
        $page_var = $this->getRequest()->getParam('page');
        if (isset($page_var) && $page_var == "shortlist") {
            $swatchHtml .= "";
        } else {
            if (!$confCategory->removeSizeGuide($cats)) {
                $swatchHtml .= '<span class="size-guide-new"><a class="show_popup" href="javascript:void(0);">Size Guide</a></span>';
            }
        }
        $i = 0;
        if ($_product->isSaleable()) {
            if ($isColorAvailable && $isSizeAvailable) {
                $swatchHtml .= '<div class="sizeColor"><span>Select colour and size</span></div>';
                foreach ($superAtt as $sAttKey => $sAttVal) {
                    $swatchHtml .= '<input type="hidden" id="' . $_product->getId() . '_' . $sAttKey . '" name="super_attribute[' . $sAttVal . ']" value="" >';
                }
                $swatchHtml .= '<div class="color-swatch-table"><table id="swatches"><tr><td>&nbsp;</td>';
                foreach ($sortedSize as $sk => $sz) {
                    $swatchHtml .= '<td style="padding-right:10px;" title="' . $sz . '"><span style="cursor: help;">' . $sortedSizeAbbr[$sk] . '</span></td>';
                }
                $swatchHtml .= '</tr>';
                foreach ($sortedOptData as $optKey => $optVal) {
                    $swatchHtml .= '<tr>';
                    $swatchNotAvailable = true;
                    $colorSwatchImageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/enterprise/lecom/images/NA.jpg';
                    foreach ($optVal as $optionKey => $optionVal) {
                        $thumbProduct = Mage::getModel('catalog/product')->load($optionVal['simple_prod_id']);
                        if ($swatchNotAvailable) {
                            $colorSwatchImage = $thumbProduct->getColorSwatchImage();
                            if (!empty($colorSwatchImage) and $colorSwatchImage != "no_selection" and file_exists(Mage::getBaseDir('media') . DS . 'catalog/product' . $colorSwatchImage)) {
                                $colorSwatchImageUrl = Mage::helper('catalog/image')->init($thumbProduct, 'color_swatch_image')->__toString();
                                $swatchNotAvailable = false;
                                break;
                            }
                        }
                    }
                    $swatchHtml .= '<td style="padding-right:10px; padding-top:10px;"><a href="javascript:void(0);" id="' . $_product->getId() . '_' . $optKey . '" title="' . $color['color'][$optKey] . '" class="colorswatchProd" onmouseover="javascript:changeImageHovercolor(this);" onmouseout="javascript:restoreImagecolor();" ><div style="width:20px;height:20px;"><img style="width:20px;height:20px;cursor:pointer;" src="' . $colorSwatchImageUrl . '"></div></a></td> ';
                    foreach ($optVal as $optionKey => $optionVal) {
                        $thumbProduct = Mage::getModel('catalog/product')->load($optionVal['simple_prod_id']);
                        $baseImageUrl = Mage::helper('catalog/image')->init($thumbProduct, 'image');
                        $prod_fprice = Mage::helper('common')->currency($optionVal['finalPrice']);
                        $prod_fprice = str_replace('class="WebRupee"', 'class=WebRupee', $prod_fprice);
                        $prod_price = Mage::helper('common')->currency($optionVal['price']);
                        $prod_price = str_replace('class="WebRupee"', 'class=WebRupee', $prod_price);
                        $swatchHtml .= '<td style="padding-right:10px; padding-top:10px;" id="' . $optionVal['simple_prod_id'] . '">';
                        if ($optionVal['stock']) {
                            $url_image_1 = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/enterprise/lecom/images';
                            $url_image_2 = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/enterprise/lecom/images/available_1.jpg';
                            if (isset($page_var) && $page_var == "shortlist") {
                                //$swatchHtml .= '<a href="javascript:void(0);" class="swatchProd" id="'.$_product->getId().'_'.$optKey.'_'.$optionKey.'" onmouseover="javascript:changeImageHover(this);" onmouseout="javascript:restoreImage(this);" onclick="selectOption(\''.$_product->getId().'\',\''.$optKey.'\',\''.$optionKey.'\',\''.$url_image_1.'\');changeImage(\''.$_product->getId().'\',\''.$optionVal['simple_prod_id'].'\',\''.number_format($optionVal['finalPrice'],2).'\',\''.number_format($optionVal['price'],2).'\');"><img width="20" height="20" alt="Available" title="Available" id="'.$_product->getId().'_'.$optKey.'_'.$optionKey.'_opt" src="'.$url_image_2.'" /></a>';
                                $swatchHtml .= '<a href="javascript:void(0);" class="swatchProd" id="' . $_product->getId() . '_' . $optKey . '_' . $optionKey . '" onclick="selectOption(\'' . $_product->getId() . '\',\'' . $optKey . '\',\'' . $optionKey . '\',\'' . $url_image_1 . '\');changeImage(\'' . $_product->getId() . '\',\'' . $optionVal['simple_prod_id'] . '\',\'' . number_format($optionVal['finalPrice'], 2) . '\',\'' . number_format($optionVal['price'], 2) . '\',\'' . $prod_fprice . '\',\'' . $prod_price . '\');changeMoreView(\'' . $optionVal['simple_prod_id'] . '\',\'' . $_product_id . '\');"><img width="20" height="20" alt="Available" title="Available" id="' . $_product->getId() . '_' . $optKey . '_' . $optionKey . '_opt" src="' . $url_image_2 . '" /></a>';
                            } else {
                                $swatchHtml .= '<a href="javascript:void(0);" class="swatchProd" id="' . $_product->getId() . '_' . $optKey . '_' . $optionKey . '" onmouseover="javascript:changeImageHover(this);" onmouseout="javascript:restoreImage(this);" onclick="selectOption(\'' . $_product->getId() . '\',\'' . $optKey . '\',\'' . $optionKey . '\',\'' . $url_image_1 . '\');changeImage(\'' . $_product->getId() . '\',\'' . $optionVal['simple_prod_id'] . '\',\'' . number_format($optionVal['finalPrice'], 2) . '\',\'' . number_format($optionVal['price'], 2) . '\');changeMoreView(\'' . $optionVal['simple_prod_id'] . '\',\'\');"><img width="20" height="20" alt="Available" title="Available" id="' . $_product->getId() . '_' . $optKey . '_' . $optionKey . '_opt" src="' . $url_image_2 . '" /></a>';
                            }
                        } else {
                            $swatchHtml .= '<img width="20" height="20" alt="Out of stock" title="Out of stock" src="' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/enterprise/lecom/images/not_available.jpg' . '" />';
                        }
                        if ($_smpproductId == $optionVal['simple_prod_id']) {
                            $url_image_3 = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/enterprise/lecom/images';
                            // Select the same simple product on PDP when coming from wishlist
                            $swatchHtml .= '<script type="text/javascript">selectOption(\'' . $_product->getId() . '\',\'' . $optKey . '\',\'' . $optionKey . '\',\'' . $url_image_3 . '\');changeImage(\'' . $_product->getId() . '\',\'' . $optionVal['simple_prod_id'] . '\',\'' . number_format($optionVal['finalPrice'], 2) . '\',\'' . number_format($optionVal['price'], 2) . '\');changeMoreView(\'' . $optionVal['simple_prod_id'] . '\',\'\');</script>';
                        }
                        $assigned = true;
                        if ($optionVal['image'] && $optionVal['small_image'] && $assigned) {
                            $assigned = false;
                            $swatchHtml .= '<input type="hidden" class="main-image-changed" id="' . $_product->getId() . '_' . $optKey . '_' . $optionKey . '_image" rel="' . $optionVal['image'] . '" value="' . Mage::helper('catalog/image')->init($_product, 'image')->resize(395, 413)->__toString() . '" />';
                            $swatchHtml .= '<input type="hidden" id="' . $_product->getId() . '_' . $optKey . '_color_img_main_image" name="' . $optKey . '_color" value="' . $optionVal['simple_prod_id'] . '" rel="' . $optionVal['image'] . '" />';
                            $swatchHtml .= '<input type="hidden" id="' . $_product->getId() . '_' . $optKey . '_color_img_lightbox_image" name="' . $optKey . '_color_lightbox" value="' . $baseImageUrl->resize($lightbox_image_resize_width, $lightbox_image_resize_height)->__toString() . '" />';
                            $swatchHtml .= '<input type="hidden" id="' . $_product->getId() . '_' . $optKey . '_color_small_img" name="' . $optKey . '_small_color" value="' . $optionVal['small_image'] . '" />';
                            $swatchHtml .= '<input type="hidden" id="' . $_product->getId() . '_' . $optKey . '_moreviewId" name="moreviewId" value="' . $optionVal['simple_prod_id'] . '" />';
                            $swatchHtml .= '</td>';
                        }
                    }
                    $swatchHtml .= '</tr>';
                }
                $url_image_4 = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/enterprise/lecom/images/selected.jpg';
                $url_image_5 = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/enterprise/lecom/images/available_1.jpg';
                $url_image_6 = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/enterprise/lecom/images/not_available.jpg';
                $swatchHtml .= '</table></div><div class="helper-images"><span><img width="15" height="15" src="' . $url_image_4 . '" /> Selected   </span><img width="15" height="15" src="' . $url_image_5 . '" /> In stock   </span><img width="15" height="15" src="' . $url_image_6 . '" /> Out of stock   </span></div>';
            } else {
                // Default view
                $swatchHtml .= '<div class="sizeColor">Select colour and size</div><dl>';
                /*
                foreach($_attributes as $_attribute){
                	if ($_attribute->decoratedIsLast){
                		$swatchHtml .= '<dd id="'.$_product->getId().'_item_'.++$i.'" class="last">';
                	}else{
                		$swatchHtml .= '<dd id="'.$_product->getId().'_item_'.++$i.'">';
                	}
                	
                	$swatchHtml .= '<div class="input-box" style="background:none !important;">';
                	$swatchHtml .= '<select  name="super_attribute['.$_attribute->getAttributeId().']" id="attribute'.$_attribute->getAttributeId().'" class="super-attribute-select_'.$_product->getId().'" onchange="resetOption('.$_product->getId().','.$i.');"><option>';
                	      if(stristr($_attribute->getLabel(),"color")) 
                		    $swatchHtml .= 'Select Colour'; 
                		  elseif(stristr($_attribute->getLabel(), "size")) 
                		    $swatchHtml .= 'Select Size'; 
                		  else
                		    $swatchHtml .= 'Select Option';
                	$swatchHtml .= '</option></select>';
                	
                	if ($_attribute->decoratedIsLast){
                		$cats = $_product->getCategoryIds();
                		if(!$confCategory->removeSizeGuide($cats)){			 
                			$swatchHtml .= '<a class="show_popup" href="javascript:void(0);">Size Guide</a>';
                		} 
                	}
                	
                	$swatchHtml .='</div></dd>';
                }
                */
                $swatchHtml .= '</dl>';
                $swatchHtml .= '<script type="text/javascript">var spConfig_' . $_product->getId() . ' = new FCM_Product.Config(' . $obj->getJsonConfig() . ');var selectedAssocProducts_' . $_product->getId() . ' = {};</script>';
            }
            $swatchHtml .= '<script type="text/javascript">jQuery(".show_popup").click(function() {jQuery("#fancybox-outer1").css({top:20}).show(); jQuery("#fancybox-overlay1")
jQuery("#fancybox-wrap1,#fancybox-overlay1").fadeIn(300);
});
</script>';
        }
        $this->getResponse()->setBody($swatchHtml);
    }
 protected function _prepareOldPrice($price, $isPercent = false)
 {
     if (version_compare(Mage::getVersion(), '1.7.0.0') < 0) {
         return $this->_preparePrice($price, $isPercent);
     } else {
         return parent::_prepareOldPrice($price, $isPercent);
     }
 }
Example #23
0
 /**
  * Retrieve all products associated with a configurable product
  *
  * @param int $parentId
  * @return array
  */
 public function getChildrenFromConfigurableProduct()
 {
     // result
     $result = array();
     // get loaded product
     $product = $this->getProduct();
     if ($product->getId()) {
         // retrieve associated products
         if (version_compare(Mage::getVersion(), '1.3.0.0', '>=')) {
             $children = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
             if (count($children)) {
                 foreach ($children as $arr) {
                     $result = $arr;
                     break;
                 }
             }
         } else {
             if (version_compare(Mage::getVersion(), '1.1.3.0', '>=')) {
                 $result = array();
                 // get new config block
                 $configBlock = new Mage_Catalog_Block_Product_View_Type_Configurable();
                 // load product into config block
                 $configBlock->setProduct($product);
                 // get child products
                 $options = $configBlock->getAllowProducts();
                 // loop options
                 if (count($options)) {
                     foreach ($options as $o) {
                         $result[] = $o;
                     }
                 }
                 // save memory
                 unset($configBlock);
             }
         }
     }
     return $result;
 }