/**
  * Get product thumbnail image
  *
  * @return Mage_Catalog_Model_Product_Image
  */
 public function getProductThumbnail()
 {
     if (Mage::getStoreConfig("attributeswatches/checkout/overrideimage")) {
         $_atts = explode(",", Mage::getStoreConfig("attributeswatches/settings/switchimage"));
         if (!count($_atts)) {
             parent::getProductThumbnail();
         }
         /* get combinations attribute{attributeid}-{value} */
         $product_instance = $this->getProduct()->getTypeInstance(true);
         $attributesOption = $product_instance->getProduct($this->getProduct())->getCustomOption('attributes');
         $_values = unserialize($attributesOption->getValue());
         $usedProductAttributesData = array();
         foreach ($product_instance->getConfigurableAttributes($this->getProduct()) as $attribute) {
             if (!is_null($attribute->getProductAttribute()) && isset($_values[$attribute->getProductAttribute()->getId()]) && in_array($attribute->getProductAttribute()->getAttributeCode(), $_atts)) {
                 $id = $attribute->getProductAttribute()->getId();
                 $usedProductAttributesData[$attribute->getProductAttribute()->getAttributeCode()] = "attribute" . $id . "-" . $_values[$id];
             }
         }
         $_images = Mage::getResourceSingleton('catalog/product_attribute_backend_media')->loadCartImage($this->getProduct(), $usedProductAttributesData);
         if (!count($_images)) {
             return parent::getProductThumbnail();
         }
         return $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_images[0]["file"]);
     } else {
         return parent::getProductThumbnail();
     }
 }
 public function getOptionList()
 {
     $item = $this->getItem();
     if (file_exists(Mage::getBaseDir() . '/app/code/core/' . 'Mage/Catalog/Helper/Product/Configuration.php')) {
         $helper = Mage::helper('catalog/product_configuration');
         $product = $item->getProduct();
         $attributes = $product->getTypeInstance(true)->getSelectedAttributesInfo($product);
         return array_merge($this->_getSarpOptions(), $attributes, $helper->getCustomOptions($item));
     } else {
         return array_merge($this->_getSarpOptions(), parent::getOptionList());
     }
 }
Exemple #3
0
 public function getOptionList()
 {
     $options = parent::getOptionList();
     $item = $this->getItem();
     $giftwrapItem = Mage::getModel('giftwrap/selectionitem')->getCollection()->addFieldToFilter('item_id', $item->getId())->getFirstItem();
     $giftbox = Mage::getModel('giftwrap/selection')->load($giftwrapItem->getSelectionId());
     $giftwrap = Mage::getModel('giftwrap/giftwrap')->load($giftbox->getStyleId());
     $giftcard = Mage::getModel('giftwrap/giftcard')->load($giftbox->getGiftcardId());
     if ($giftwrapItem->getId()) {
         $options[] = array('label' => Mage::helper('giftwrap')->__('Gift Wrap'), 'value' => $this->htmlEscape($giftwrap->getTitle()));
         if ($giftcard->getId()) {
             $options[] = array('label' => Mage::helper('giftwrap')->__('Gift Card'), 'value' => $this->htmlEscape($giftcard->getName()));
         }
         if ($giftbox->getMessage()) {
             $options[] = array('label' => Mage::helper('giftwrap')->__('Gift Message'), 'value' => $this->htmlEscape($giftbox->getMessage()));
         }
     }
     return $options;
 }
 public function getFormatedOptionValue($optionValue)
 {
     $helper = Mage::helper('flycart');
     if ($helper->isActivated()) {
         if (!$helper->isOtherVersion(1, 5) && Mage::getStoreConfig('flycart/qtyupdate/cart_page') && (Mage::helper('flycart')->isCartPage() || Mage::helper('flycart')->isChangedAttributeCart() || Mage::helper('flycart')->isChangedQtyCart())) {
             $optionInfo = array();
             if (is_array($optionValue)) {
                 if (isset($optionValue['option_id'])) {
                     $optionInfo = $optionValue;
                     if (isset($optionInfo['value'])) {
                         $optionValue = $optionInfo['value'];
                     }
                 } elseif (isset($optionValue['value'])) {
                     $optionValue = $optionValue['value'];
                 }
             }
             if (isset($optionInfo['custom_view']) && $optionInfo['custom_view']) {
                 $_default = array('value' => $optionValue);
                 if (isset($optionInfo['option_type'])) {
                     try {
                         $group = Mage::getModel('catalog/product_option')->groupFactory($optionInfo['option_type']);
                         return array('value' => $group->getCustomizedView($optionInfo));
                     } catch (Exception $e) {
                         return $_default;
                     }
                 }
                 return $_default;
             }
             $result = array();
             if (is_array($optionValue)) {
                 $_truncatedValue = implode("\n", $optionValue);
                 $_truncatedValue = nl2br($_truncatedValue);
                 return array('value' => $_truncatedValue);
             } else {
                 $_truncatedValue = nl2br($optionValue);
             }
             $result = array('value' => $_truncatedValue);
             return $result;
         } else {
             return parent::getFormatedOptionValue($optionValue);
         }
     } else {
         return parent::getFormatedOptionValue($optionValue);
     }
 }
 /**
  * Return merged options array
  * This array consist of standard Magento options and booking
  * @return array
  */
 public function getOptionList()
 {
     return array_merge($this->_getOptions(), parent::getOptionList());
 }
 public function getFormatedOptionValue($optionValue)
 {
     $helper = Mage::helper('adodis_ajaxcart');
     if ($helper->isAjaxCartEnable()) {
         if (!$helper->getIsAnymoreVersion(1, 5) && Mage::getStoreConfig('adodis_ajaxcart/qty_settings/cart_page') && (Mage::helper('adodis_ajaxcart')->getIsCartPage() || Mage::helper('adodis_ajaxcart')->getChangeAttributeCart() || Mage::helper('adodis_ajaxcart')->getChangeQtyCart())) {
             $optionInfo = array();
             // define input data format
             if (is_array($optionValue)) {
                 if (isset($optionValue['option_id'])) {
                     $optionInfo = $optionValue;
                     if (isset($optionInfo['value'])) {
                         $optionValue = $optionInfo['value'];
                     }
                 } elseif (isset($optionValue['value'])) {
                     $optionValue = $optionValue['value'];
                 }
             }
             // render customized option view
             if (isset($optionInfo['custom_view']) && $optionInfo['custom_view']) {
                 $_default = array('value' => $optionValue);
                 if (isset($optionInfo['option_type'])) {
                     try {
                         $group = Mage::getModel('catalog/product_option')->groupFactory($optionInfo['option_type']);
                         return array('value' => $group->getCustomizedView($optionInfo));
                     } catch (Exception $e) {
                         return $_default;
                     }
                 }
                 return $_default;
             }
             // truncate standard view
             $result = array();
             if (is_array($optionValue)) {
                 $_truncatedValue = implode("\n", $optionValue);
                 $_truncatedValue = nl2br($_truncatedValue);
                 return array('value' => $_truncatedValue);
             } else {
                 $_truncatedValue = nl2br($optionValue);
             }
             $result = array('value' => $_truncatedValue);
             return $result;
         } else {
             return parent::getFormatedOptionValue($optionValue);
         }
     } else {
         return parent::getFormatedOptionValue($optionValue);
     }
 }