/**
  * Prepare custom option for display, returns false if there's no value
  *
  * @param string $code
  * @return mixed
  */
 public function prepareCustomOption(Mage_Catalog_Model_Product_Configuration_Item_Interface $item, $code)
 {
     $option = $item->getOptionByCode($code);
     if ($option) {
         $value = $option->getValue();
         if ($value) {
             return $this->escapeHtml($value);
         }
     }
     return false;
 }
 /**
  * Retreve the product attributes
  *
  * @param Mage_Catalog_Model_Product_Configuration_Item_Interface $item
  * @return array
  */
 protected function _getAttributes($item)
 {
     $itemId = $item->getId();
     if (!isset($this->_finished[$itemId])) {
         $this->_finished[$itemId] = true;
         $product = $this->_getProduct($item);
         $attributes = $this->_getAdditionalData($product);
         if (count($attributes) > 0) {
             return $attributes;
         }
     }
     return array();
 }
 /**
  * Retrieves product options list
  *
  * @param Mage_Catalog_Model_Product_Configuration_Item_Interface $item
  * @return array
  */
 public function getOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
 {
     $typeId = $item->getProduct()->getTypeId();
     switch ($typeId) {
         case Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE:
             return $this->getConfigurableOptions($item);
             break;
         case Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE:
             return $this->getGroupedOptions($item);
             break;
     }
     return array_merge($this->_getOptions($item), $this->getCustomOptions($item));
 }
 /**
  * Retrieves item links options
  *
  * @param Mage_Catalog_Model_Product_Configuration_Item_Interface $item
  * @return array
  */
 public function getLinks(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
 {
     $product = $item->getProduct();
     $itemLinks = array();
     $linkIds = $item->getOptionByCode('downloadable_link_ids');
     if ($linkIds) {
         $productLinks = $product->getTypeInstance(true)->getLinks($product);
         foreach (explode(',', $linkIds->getValue()) as $linkId) {
             if (isset($productLinks[$linkId])) {
                 $itemLinks[] = $productLinks[$linkId];
             }
         }
     }
     return $itemLinks;
 }
 /**
  * Get bundled selections (slections-products collection)
  *
  * Returns array of options objects.
  * Each option object will contain array of selections objects
  *
  * @return array
  */
 public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
 {
     $options = array();
     $product = $item->getProduct();
     if (!Mage::helper('ho_simplebundle')->isBundleProductSimple($product)) {
         return parent::getBundleOptions($item);
     }
     /**
      * @var Mage_Bundle_Model_Product_Type
      */
     $typeInstance = $product->getTypeInstance(true);
     // get bundle options
     $optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
     $bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array();
     if ($bundleOptionsIds) {
         /**
          * @var Mage_Bundle_Model_Mysql4_Option_Collection
          */
         $optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
         // get and add bundle selections collection
         $selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
         $bundleSelectionIds = unserialize($selectionsQuoteItemOption->getValue());
         if (!empty($bundleSelectionIds)) {
             $selectionsCollection = $typeInstance->getSelectionsByIds(unserialize($selectionsQuoteItemOption->getValue()), $product);
             $bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
             foreach ($bundleOptions as $bundleOption) {
                 if ($bundleOption->getSelections()) {
                     $option = array('label' => $bundleOption->getTitle(), 'value' => array());
                     $bundleSelections = $bundleOption->getSelections();
                     foreach ($bundleSelections as $bundleSelection) {
                         $qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
                         if ($qty) {
                             $option['value'][] = $qty . ' × ' . $this->escapeHtml($bundleSelection->getName());
                         }
                     }
                     if ($option['value']) {
                         $options[] = $option;
                     }
                 }
             }
         }
     }
     return $options;
 }
Beispiel #6
0
 /**
  * Get bundled selections (slections-products collection)
  *
  * Returns array of options objects.
  * Each option object will contain array of selections objects
  *
  * @return array
  */
 public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
 {
     $options = array();
     $product = $item->getProduct();
     $foundItem = Mage::getModel("catalog/product")->load($product->getId());
     /**
      * @var Mage_Bundle_Model_Product_Type
      */
     $typeInstance = $product->getTypeInstance(true);
     // get bundle options
     $optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
     $bundleOptionsIds = unserialize($optionsQuoteItemOption->getValue());
     if ($bundleOptionsIds) {
         /**
          * @var Mage_Bundle_Model_Mysql4_Option_Collection
          */
         $optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
         // get and add bundle selections collection
         $selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
         $selectionsCollection = $typeInstance->getSelectionsByIds(unserialize($selectionsQuoteItemOption->getValue()), $product);
         $bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
         foreach ($bundleOptions as $bundleOption) {
             if ($bundleOption->getSelections()) {
                 $option = array('label' => $bundleOption->getTitle(), 'value' => array());
                 $bundleSelections = $bundleOption->getSelections();
                 foreach ($bundleSelections as $bundleSelection) {
                     $qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
                     if ($qty) {
                         if (!Mage::helper('not2order')->getShowPrice($foundItem)) {
                             $option['value'][] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName());
                         } else {
                             $option['value'][] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName()) . ' ' . Mage::helper('core')->currency($this->getSelectionFinalPrice($item, $bundleSelection));
                         }
                     }
                 }
                 if ($option['value']) {
                     $options[] = $option;
                 }
             }
         }
     }
     return $options;
 }
 /**
  * Retrieves configuration options for configurable product
  *
  * @param Mage_Catalog_Model_Product_Configuration_Item_Interface $item
  * @return array
  */
 public function getConfigurableOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
 {
     $product = $item->getProduct();
     $typeId = $product->getTypeId();
     if ($typeId != Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
         Mage::throwException($this->__('Wrong product type to extract configurable options.'));
     }
     $attributes = $product->getTypeInstance(true)->getSelectedAttributesInfo($product);
     foreach ($item->getChildren() as $conf_item) {
         $_params = unserialize($conf_item->getOptionByCode('info_buyRequest')->getValue());
         if (isset($_params['additional_options'])) {
             try {
                 $add_opts = end($_params['additional_options']);
                 $total_points += intval($add_opts['orgi_value']) * $conf_item->getQty();
             } catch (Exception $e) {
                 Mage::log($e->getMessage());
             }
         }
     }
     if ($total_points > 0) {
         $attributes = array_merge(array(array('label' => Mage::helper('rewardpoints')->__('Sell in Points'), 'value' => Mage::helper('rewardpoints')->formatPoints($total_points, $store_id))), $attributes);
     }
     return array_merge($attributes, $this->getCustomOptions($item));
 }
 /**
  * Get bundled selections (slections-products collection)
  *
  * Returns array of options objects.
  * Each option object will contain array of selections objects
  *
  * @return array
  */
 public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
 {
     $options = array();
     $product = $item->getProduct();
     /**
      * @var Mage_Bundle_Model_Product_Type
      */
     $typeInstance = $product->getTypeInstance(true);
     // get bundle options
     $optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
     $additional_options = array();
     $total_points = 0;
     foreach ($item->getChildren() as $bundle_item) {
         $_params = unserialize($bundle_item->getOptionByCode('info_buyRequest')->getValue());
         if (isset($_params['additional_options'])) {
             try {
                 $add_opts = end($_params['additional_options']);
                 $additional_options[$bundle_item->getProductId()] = $add_opts;
                 $total_points += intval($add_opts['orgi_value']);
             } catch (Exception $e) {
                 Mage::log($e->getMessage());
             }
         }
     }
     $store_id = Mage::app()->getStore()->getId();
     if ($total_points > 0) {
         $options[] = array('label' => Mage::helper('rewardpoints')->__('Sell in Points'), 'value' => array(Mage::helper('rewardpoints')->formatPoints($total_points, $store_id)));
     }
     $bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array();
     if ($bundleOptionsIds) {
         /**
          * @var Mage_Bundle_Model_Mysql4_Option_Collection
          */
         $optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
         // get and add bundle selections collection
         $selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
         $bundleSelectionIds = unserialize($selectionsQuoteItemOption->getValue());
         if (!empty($bundleSelectionIds)) {
             $selectionsCollection = $typeInstance->getSelectionsByIds(unserialize($selectionsQuoteItemOption->getValue()), $product);
             $bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
             foreach ($bundleOptions as $bundleOption) {
                 if ($bundleOption->getSelections()) {
                     $option = array('label' => $bundleOption->getTitle(), 'value' => array());
                     $bundleSelections = $bundleOption->getSelections();
                     foreach ($bundleSelections as $bundleSelection) {
                         $qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
                         if ($qty) {
                             $option['value'][] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName()) . ' ' . Mage::helper('core')->currency($this->getSelectionFinalPrice($item, $bundleSelection));
                             if (isset($additional_options[$bundleSelection->getId()]) && $additional_options[$bundleSelection->getId()]) {
                                 /*$option['value'][] = "<dt>".$additional_options[$bundleSelection->getId()]['label'] . "-" ."</dt><dd>".$additional_options[$bundleSelection->getId()]['value']."</dd>";*/
                             }
                         }
                     }
                     if ($option['value']) {
                         $options[] = $option;
                     }
                 }
             }
         }
     }
     return $options;
 }
 /**
  * Get bundled selections (slections-products collection)
  *
  * Returns array of options objects.
  * Each option object will contain array of selections objects
  *
  * @return array
  */
 public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
 {
     $options = array();
     $product = $item->getProduct();
     /**
      * @var Mage_Bundle_Model_Product_Type
      */
     $typeInstance = $product->getTypeInstance(true);
     // get bundle options
     $optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
     $bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array();
     if ($bundleOptionsIds) {
         /**
          * @var Mage_Bundle_Model_Mysql4_Option_Collection
          */
         $optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
         // get and add bundle selections collection
         $selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
         $selectionsCollection = $typeInstance->getSelectionsByIds(unserialize($selectionsQuoteItemOption->getValue()), $product);
         $bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
         foreach ($bundleOptions as $bundleOption) {
             if ($bundleOption->getSelections()) {
                 $option = array('label' => $bundleOption->getTitle(), 'value' => array());
                 $bundleSelections = $bundleOption->getSelections();
                 foreach ($bundleSelections as $bundleSelection) {
                     $qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
                     if ($qty) {
                         $val = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName()) . ' ';
                         if ($bundleSelection->getTypeId() == 'reservation') {
                             if ($product->getBundlePricingtype() == ITwebexperts_Payperrentals_Model_Product_Bundlepricingtype::PRICING_BUNDLE_PERPRODUCT) {
                                 $customerGroup = ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup();
                                 if (!is_object($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION))) {
                                     $source = unserialize($product->getCustomOption('info_buyRequest')->getValue());
                                     if (isset($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION])) {
                                         $start_date = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION];
                                         $end_date = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION];
                                     }
                                 } else {
                                     $start_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION)->getValue();
                                     $end_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION)->getValue();
                                 }
                                 $data = new Varien_Object(array('start_date' => $start_date, 'end_date' => $end_date));
                                 Mage::dispatchEvent('payperrentals_bundle_option_calculate_price_before', array('data' => $data, 'item' => $item, 'selection' => $bundleSelection));
                                 extract($data->getData(), EXTR_OVERWRITE);
                                 $priceAmount = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($bundleSelection, $start_date, $end_date, $qty, $customerGroup);
                                 $val .= Mage::helper('core')->currency($priceAmount);
                             } else {
                             }
                         } else {
                             $val .= Mage::helper('core')->currency($this->getSelectionFinalPrice($item, $bundleSelection));
                         }
                         $option['value'][] = $val;
                     }
                 }
                 if ($option['value']) {
                     $options[] = $option;
                 }
             }
         }
     }
     return $options;
 }
Beispiel #10
0
 /**
  * Retrieves product configuration options
  *
  * @param Mage_Catalog_Model_Product_Configuration_Item_Interface $item
  * @return array
  */
 public function getCustomOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
 {
     $product = $item->getProduct();
     $options = array();
     $optionIds = $item->getOptionByCode('option_ids');
     if ($optionIds) {
         $options = array();
         foreach (explode(',', $optionIds->getValue()) as $optionId) {
             $option = $product->getOptionById($optionId);
             if ($option) {
                 $itemOption = $item->getOptionByCode('option_' . $option->getId());
                 $group = $option->groupFactory($option->getType())->setOption($option)->setConfigurationItem($item)->setConfigurationItemOption($itemOption);
                 if ('file' == $option->getType()) {
                     $downloadParams = $item->getFileDownloadParams();
                     if ($downloadParams) {
                         $url = $downloadParams->getUrl();
                         if ($url) {
                             $group->setCustomOptionDownloadUrl($url);
                         }
                         $urlParams = $downloadParams->getUrlParams();
                         if ($urlParams) {
                             $group->setCustomOptionUrlParams($urlParams);
                         }
                     }
                 }
                 $options[] = array('label' => $option->getTitle(), 'value' => $group->getFormattedOptionValue($itemOption->getValue()), 'print_value' => $group->getPrintableOptionValue($itemOption->getValue()), 'option_id' => $option->getId(), 'option_type' => $option->getType(), 'custom_view' => $group->isCustomizedView());
             }
         }
     }
     $addOptions = $item->getOptionByCode('additional_options');
     if ($addOptions) {
         $options = array_merge($options, unserialize($addOptions->getValue()));
     }
     return $options;
 }