当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Sales_Model_Order_Item::getProductOptionByCode方法代码示例

本文整理汇总了PHP中Mage_Sales_Model_Order_Item::getProductOptionByCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Item::getProductOptionByCode方法的具体用法?PHP Mage_Sales_Model_Order_Item::getProductOptionByCode怎么用?PHP Mage_Sales_Model_Order_Item::getProductOptionByCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Sales_Model_Order_Item的用法示例。


在下文中一共展示了Mage_Sales_Model_Order_Item::getProductOptionByCode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getItemSku

 /**
  * Returns the sku of the given item dependant on the product type.
  *
  * @param Mage_Sales_Model_Order_Item $item The item to return info from
  * @return String The sku
  */
 protected function getItemSku($item)
 {
     if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         return $item->getProductOptionByCode('simple_sku');
     }
     return $item->getSku();
 }
开发者ID:rob3000,项目名称:fontis_australia,代码行数:13,代码来源:Abstract.php

示例2: addOrderItem

 /**
  * Convert order item to quote item
  *
  * @param Mage_Sales_Model_Order_Item $orderItem
  * @param mixed $qtyFlag if is null set product qty like in order
  * @return Mage_Checkout_Model_Cart
  */
 public function addOrderItem($orderItem, $qtyFlag = null)
 {
     /* @var $orderItem Mage_Sales_Model_Order_Item */
     if (is_null($orderItem->getParentItem())) {
         $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($orderItem->getProductId());
         if (!$product->getId()) {
             return $this;
         }
         $info = $orderItem->getProductOptionByCode('info_buyRequest');
         $info = new Varien_Object($info);
         if (is_null($qtyFlag)) {
             $info->setQty($orderItem->getQtyOrdered());
         } else {
             $info->setQty(1);
         }
         $this->addProduct($product, $info);
     }
     return $this;
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:26,代码来源:Cart.php

示例3: initFromOrderItem

 /**
  * Initialize creation data from existing order Item
  *
  * @param Mage_Sales_Model_Order_Item $orderItem
  * @param int $qty
  * @return Mage_Sales_Model_Quote_Item | string
  */
 public function initFromOrderItem(Mage_Sales_Model_Order_Item $orderItem, $qty = null)
 {
     if (!$orderItem->getId()) {
         return $this;
     }
     $product = Mage::getModel('catalog/product')->setStoreId($this->getSession()->getStoreId())->load($orderItem->getProductId());
     if ($product->getId()) {
         $product->setSkipCheckRequiredOption(true);
         $buyRequest = $orderItem->getBuyRequest();
         if (is_numeric($qty)) {
             $buyRequest->setQty($qty);
         }
         $item = $this->getQuote()->addProduct($product, $buyRequest);
         if (is_string($item)) {
             return $item;
         }
         if ($additionalOptions = $orderItem->getProductOptionByCode('additional_options')) {
             $item->addOption(new Varien_Object(array('product' => $item->getProduct(), 'code' => 'additional_options', 'value' => serialize($additionalOptions))));
         }
         Mage::dispatchEvent('sales_convert_order_item_to_quote_item', array('order_item' => $orderItem, 'quote_item' => $item));
         return $item;
     }
     return $this;
 }
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:31,代码来源:Create.php

示例4: _sendEmail

 /**
  * Send email to giftcard recipient
  *
  * @param Mage_Sales_Model_Order_Item $item
  * @param int $numGiftCardsToSend
  * @return void
  */
 protected function _sendEmail($item, $numGiftCardsToSend)
 {
     if ($numGiftCardsToSend <= 0) {
         return;
     }
     $options = $item->getProductOptions();
     $createdGiftCardCodes = isset($options['giftcard_created_codes']) ? $options['giftcard_created_codes'] : array();
     $sentCodes = isset($options['giftcard_sent_codes']) ? $options['giftcard_sent_codes'] : array();
     $sentCodesQty = count($sentCodes);
     $availableCodes = $sentCodesQty > 0 ? array_diff($createdGiftCardCodes, $sentCodes) : $createdGiftCardCodes;
     if (count($availableCodes) <= 0) {
         return;
     }
     $newlySentCodes = array();
     $numNewlySentCodes = 0;
     foreach ($availableCodes as $code) {
         $newlySentCodes[] = $code;
         $sentCodes[] = $code;
         $numNewlySentCodes++;
         if ($numNewlySentCodes == $numGiftCardsToSend) {
             break;
         }
     }
     $sender = $item->getProductOptionByCode('giftcard_sender_name');
     $senderName = $item->getProductOptionByCode('giftcard_sender_name');
     $senderEmail = $item->getProductOptionByCode('giftcard_sender_email');
     if ($senderEmail) {
         $sender = "{$sender} <{$senderEmail}>";
     }
     $isRedeemable = $this->_isGiftCardRedeemable($item);
     $amount = $item->getBasePrice();
     $store = Mage::app()->getStore($item->getOrder()->getStoreId());
     $codeList = Mage::helper('enterprise_giftcard')->getEmailGeneratedItemsBlock()->setCodes($newlySentCodes)->setIsRedeemable($isRedeemable)->setStore($store);
     $balance = Mage::app()->getLocale()->currency($store->getBaseCurrencyCode())->toCurrency($amount);
     $templateData = array('name' => $item->getProductOptionByCode('giftcard_recipient_name'), 'email' => $item->getProductOptionByCode('giftcard_recipient_email'), 'sender_name_with_email' => $sender, 'sender_name' => $senderName, 'gift_message' => $item->getProductOptionByCode('giftcard_message'), 'giftcards' => $codeList->toHtml(), 'balance' => $balance, 'is_multiple_codes' => 1 < $numNewlySentCodes, 'store' => $store, 'store_name' => $store->getName(), 'is_redeemable' => $isRedeemable);
     $email = Mage::getModel('core/email_template')->setDesignConfig(array('store' => $store->getId()));
     $email->sendTransactional($item->getProductOptionByCode('giftcard_email_template'), Mage::getStoreConfig(Enterprise_GiftCard_Model_Giftcard::XML_PATH_EMAIL_IDENTITY, $store->getId()), $item->getProductOptionByCode('giftcard_recipient_email'), $item->getProductOptionByCode('giftcard_recipient_name'), $templateData);
     $options['giftcard_sent_codes'] = $sentCodes;
     if ($email->getSentSuccess()) {
         $options['email_sent'] = 1;
     }
     $item->setProductOptions($options);
     return;
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:51,代码来源:Observer.php

示例5: reorderItem

 /**
  * Add new item to quote based on existing order Item
  *
  * @param Mage_Sales_Model_Order_Item $orderItem
  * @return Mage_Sales_Model_Quote_Item
  * @throws Mage_Core_Exception
  */
 public function reorderItem(Mage_Sales_Model_Order_Item $orderItem, $qty = 1)
 {
     if (!$orderItem->getId()) {
         Mage::throwException(Mage::helper('enterprise_checkout')->__('Failed to reorder item'));
     }
     $product = Mage::getModel('catalog/product')->setStoreId($this->getStore()->getId())->load($orderItem->getProductId());
     if ($product->getId()) {
         $info = $orderItem->getProductOptionByCode('info_buyRequest');
         $info = new Varien_Object($info);
         $product->setSkipCheckRequiredOption(true);
         $item = $this->createQuote()->addProduct($product, $info);
         if (is_string($item)) {
             Mage::throwException($item);
         }
         $item->setQty($qty);
         if ($additionalOptions = $orderItem->getProductOptionByCode('additional_options')) {
             $item->addOption(new Varien_Object(array('product' => $item->getProduct(), 'code' => 'additional_options', 'value' => serialize($additionalOptions))));
         }
         Mage::dispatchEvent('sales_convert_order_item_to_quote_item', array('order_item' => $orderItem, 'quote_item' => $item));
         return $item;
     } else {
         Mage::throwException(Mage::helper('enterprise_checkout')->__('Failed to add a product of order item'));
     }
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:31,代码来源:Cart.php

示例6: _getOrderItemOptionValues

 /**
  * Return sales item as object
  * @param Mage_Sales_Model_Order_Item $item
  * @return Varien_Object
  */
 protected function _getOrderItemOptionValues(Mage_Sales_Model_Order_Item $item)
 {
     $buyRequest = $item->getProductOptionByCode('info_buyRequest');
     $obj = new Varien_Object();
     $obj->setData($buyRequest);
     return $obj;
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:12,代码来源:Observer.php

示例7: loadOrderItemOptions

 /**
  * load option data for $item
  *
  * @param  Mage_Sales_Model_Order_Item
  * @return Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection
  */
 protected function loadOrderItemOptions(Mage_Sales_Model_Order_Item $item)
 {
     $buyRequest = $item->getProductOptionByCode('info_buyRequest');
     $attrs = isset($buyRequest['super_attribute']) ? $buyRequest['super_attribute'] : [];
     $attrTable = ['attribute_table' => Mage::getSingleton('core/resource')->getTableName('eav/attribute')];
     $options = Mage::getResourceModel('eav/entity_attribute_option_collection');
     // join with the attribute table to get the attribute code.
     $options->getSelect()->join($attrTable, 'main_table.attribute_id=attribute_table.attribute_id', ['attribute_code']);
     $options->setStoreFilter($item->getStoreId());
     $options->addFieldToFilter('main_table.attribute_id', ['in' => array_keys($attrs)]);
     $options->addFieldToFilter('main_table.option_id', ['in' => array_values($attrs)]);
     return $options;
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:19,代码来源:Orderitem.php

示例8: buildItemName

 /**
  * Returns the name for a sales item.
  * Configurable products will have their chosen options added to their name.
  * Bundle products will have their chosen child product names added.
  * Grouped products will have their parents name prepended.
  * All others will have their own name only.
  *
  * @param Mage_Sales_Model_Order_Item $item the sales item model.
  *
  * @return string
  */
 protected function buildItemName(Mage_Sales_Model_Order_Item $item)
 {
     $name = $item->getName();
     $optNames = array();
     if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
         /** @var Mage_Catalog_Model_Product_Type_Configurable $model */
         $model = Mage::getModel('catalog/product_type_configurable');
         $parentIds = $model->getParentIdsByChild($item->getProductId());
         // If the product has a configurable parent, we assume we should tag
         // the parent. If there are many parent IDs, we are safer to tag the
         // products own name alone.
         if (count($parentIds) === 1) {
             $attributes = $item->getBuyRequest()->getData('super_attribute');
             if (is_array($attributes)) {
                 foreach ($attributes as $id => $value) {
                     /** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */
                     $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($id);
                     $label = $attribute->getSource()->getOptionText($value);
                     if (!empty($label)) {
                         $optNames[] = $label;
                     }
                 }
             }
         }
     } elseif ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         $opts = $item->getProductOptionByCode('attributes_info');
         if (is_array($opts)) {
             foreach ($opts as $opt) {
                 if (isset($opt['value']) && is_string($opt['value'])) {
                     $optNames[] = $opt['value'];
                 }
             }
         }
     } elseif ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
         $opts = $item->getProductOptionByCode('bundle_options');
         if (is_array($opts)) {
             foreach ($opts as $opt) {
                 if (isset($opt['value']) && is_array($opt['value'])) {
                     foreach ($opt['value'] as $val) {
                         $qty = '';
                         if (isset($val['qty']) && is_int($val['qty'])) {
                             $qty .= $val['qty'] . ' x ';
                         }
                         if (isset($val['title']) && is_string($val['title'])) {
                             $optNames[] = $qty . $val['title'];
                         }
                     }
                 }
             }
         }
     } elseif ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_GROUPED) {
         $config = $item->getProductOptionByCode('super_product_config');
         if (isset($config['product_id'])) {
             /** @var Mage_Catalog_Model_Product $parent */
             $parent = Mage::getModel('catalog/product')->load($config['product_id']);
             $parentName = $parent->getName();
             if (!empty($parentName)) {
                 $name = $parentName . ' - ' . $name;
             }
         }
     }
     if (!empty($optNames)) {
         $name .= ' (' . implode(', ', $optNames) . ')';
     }
     return $name;
 }
开发者ID:kurtinge,项目名称:nosto-magento-extension,代码行数:77,代码来源:Order.php

示例9: initFromOrderItem

 /**
  * Initialize creation data from existing order Item
  *
  * @param Mage_Sales_Model_Order_Item $orderItem
  * @param int $qty
  * @return Mage_Sales_Model_Quote_Item | string
  */
 public function initFromOrderItem(Mage_Sales_Model_Order_Item $orderItem, $qty = null)
 {
     if (!$orderItem->getId()) {
         return $this;
     }
     $product = Mage::getModel('catalog/product')->setStoreId($this->getSession()->getStoreId())->load($orderItem->getProductId());
     if ($product->getId()) {
         $product->setSkipCheckRequiredOption(true);
         $buyRequest = $orderItem->getBuyRequest();
         if (is_numeric($qty)) {
             $buyRequest->setQty($qty);
         }
         $item = $this->getQuote()->addProduct($product, $buyRequest);
         if (is_string($item)) {
             return $item;
         }
         /*********************************************Set custom price selected starts************************************************************/
         if (!$this->getSession()->getReordered() && $orderItem->getOriginalPrice() != $orderItem->getPrice()) {
             if ($orderItem->getProductType() == 'configurable' || $orderItem->getProductType() == 'bundle') {
                 $productId = $orderItem->getProductId();
                 $quoteItemId = $orderItem->getQuoteItemId();
                 $items = $this->getQuote()->getItemsCollection();
                 foreach ($items as $item) {
                     if ($item->getProduct()->getId() == $productId && !$item->getApplyPriceFlag()) {
                         if ($orderItem->getOriginalPrice() != $orderItem->getPrice()) {
                             $item->setCustomPrice($orderItem->getPrice())->setOriginalCustomPrice($orderItem->getPrice());
                         }
                         //$item->setApplyPriceFlag(true);
                     }
                 }
             } else {
                 $item->setCustomPrice($orderItem->getPrice())->setOriginalCustomPrice($orderItem->getPrice());
             }
         }
         /*********************************************Set custom price selected ends************************************************************/
         if ($additionalOptions = $orderItem->getProductOptionByCode('additional_options')) {
             $item->addOption(new Varien_Object(array('product' => $item->getProduct(), 'code' => 'additional_options', 'value' => serialize($additionalOptions))));
         }
         Mage::dispatchEvent('sales_convert_order_item_to_quote_item', array('order_item' => $orderItem, 'quote_item' => $item));
         return $item;
     }
     return $this;
 }
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:50,代码来源:Create.php


注:本文中的Mage_Sales_Model_Order_Item::getProductOptionByCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。