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


PHP Mage_Catalog_Model_Product::getCustomOptions方法代码示例

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


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

示例1: testCustomOptionsApi

 /**
  * @covers Mage_Catalog_Model_Product::addCustomOption
  * @covers Mage_Catalog_Model_Product::setCustomOptions
  * @covers Mage_Catalog_Model_Product::getCustomOptions
  * @covers Mage_Catalog_Model_Product::getCustomOption
  * @covers Mage_Catalog_Model_Product::hasCustomOptions
  */
 public function testCustomOptionsApi()
 {
     $this->assertEquals(array(), $this->_model->getCustomOptions());
     $this->assertFalse($this->_model->hasCustomOptions());
     $this->_model->setId(99);
     $this->_model->addCustomOption('one', 'value1');
     $option = $this->_model->getCustomOption('one');
     $this->assertInstanceOf('Varien_Object', $option);
     $this->assertEquals($this->_model->getId(), $option->getProductId());
     $this->assertSame($option->getProduct(), $this->_model);
     $this->assertEquals('one', $option->getCode());
     $this->assertEquals('value1', $option->getValue());
     $this->assertEquals(array('one' => $option), $this->_model->getCustomOptions());
     $this->assertTrue($this->_model->hasCustomOptions());
     $this->_model->setCustomOptions(array('test'));
     $this->assertTrue(is_array($this->_model->getCustomOptions()));
 }
开发者ID:relue,项目名称:magento2,代码行数:24,代码来源:ProductExternalTest.php

示例2: representProduct

 /**
  * Check product representation in item
  *
  * @param   Mage_Catalog_Model_Product $product
  * @return  bool
  */
 public function representProduct($product)
 {
     $itemProduct = $this->getProduct();
     if (!$product || $itemProduct->getId() != $product->getId()) {
         return false;
     }
     /**
      * Check maybe product is planned to be a child of some quote item - in this case we limit search
      * only within same parent item
      */
     $stickWithinParent = $product->getStickWithinParent();
     if ($stickWithinParent) {
         if ($this->getParentItem() !== $stickWithinParent) {
             return false;
         }
     }
     // Check options
     $itemOptions = $this->getOptionsByCode();
     $productOptions = $product->getCustomOptions();
     if (!$this->compareOptions($itemOptions, $productOptions)) {
         return false;
     }
     if (!$this->compareOptions($productOptions, $itemOptions)) {
         return false;
     }
     return true;
 }
开发者ID:relue,项目名称:magento2,代码行数:33,代码来源:Item.php

示例3: representProduct

 /**
  * Check product representation in item
  *
  * @param   Mage_Catalog_Model_Product $product
  * @return  bool
  */
 public function representProduct($product)
 {
     $itemProduct = $this->getProduct();
     if ($itemProduct->getId() != $product->getId()) {
         return false;
     }
     $itemOptions = $this->getOptionsByCode();
     $productOptions = $product->getCustomOptions();
     if (!$this->compareOptions($itemOptions, $productOptions)) {
         return false;
     }
     if (!$this->compareOptions($productOptions, $itemOptions)) {
         return false;
     }
     return true;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:22,代码来源:Item.php

示例4: array

 function _productToOrderItem(Mage_Catalog_Model_Product $product, $qty = 1)
 {
     $rowTotal = $product->getFinalPrice() * $qty;
     $options = $product->getCustomOptions();
     $optionsByCode = array();
     foreach ($options as $option) {
         $quoteOption = Mage::getModel('sales/quote_item_option')->setData($option->getData())->setProduct($option->getProduct());
         $optionsByCode[$quoteOption->getCode()] = $quoteOption;
     }
     $product->setCustomOptions($optionsByCode);
     $options = $product->getTypeInstance(true)->getOrderOptions($product);
     $orderItem = Mage::getModel('sales/order_item')->setStoreId($this->_storeId)->setQuoteItemId(0)->setQuoteParentItemId(NULL)->setProductId($product->getId())->setProductType($product->getTypeId())->setQtyBackordered(NULL)->setTotalQtyOrdered($product['rqty'])->setQtyOrdered($product['qty'])->setName($product->getName())->setSku($product->getSku())->setPrice($product->getFinalPrice())->setBasePrice($product->getFinalPrice())->setOriginalPrice($product->getFinalPrice())->setRowTotal($rowTotal)->setBaseRowTotal($rowTotal)->setWeeeTaxApplied(serialize(array()))->setBaseWeeeTaxDisposition(0)->setWeeeTaxDisposition(0)->setBaseWeeeTaxRowDisposition(0)->setWeeeTaxRowDisposition(0)->setBaseWeeeTaxAppliedAmount(0)->setBaseWeeeTaxAppliedRowAmount(0)->setWeeeTaxAppliedAmount(0)->setWeeeTaxAppliedRowAmount(0)->setProductOptions($options);
     $this->_subTotal += $rowTotal;
     return $orderItem;
 }
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:15,代码来源:Posorder.php

示例5: array

 /**
  * add product in order
  *
  * @param Mage_Catalog_Model_Product $product
  * @param int $qty
  * @param $price
  * @return Mage_Sales_Model_Order_Item
  */
 function _productToOrderItem(Mage_Catalog_Model_Product $product, $qty = 1, $price)
 {
     $options = $product->getCustomOptions();
     $optionsByCode = array();
     $bundleOptSelAttr = null;
     foreach ($options as $option) {
         $quoteOption = Mage::getModel('sales/quote_item_option')->setData($option->getData())->setProduct($option->getProduct());
         if ($quoteOption->getCode() == 'bundle_selection_attributes') {
             $bundleOptSelAttr = $quoteOption->getValue();
         }
         $optionsByCode[$quoteOption->getCode()] = $quoteOption;
     }
     $product->setCustomOptions($optionsByCode);
     // DECREMENTE O STOCK
     $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
     if ($stockItem->getManageStock()) {
         $stockItem->setData('qty', $stockItem->getQty() - $product['cart_qty']);
     }
     $stockItem->save();
     $options = $product->getTypeInstance(true)->getOrderOptions($product);
     if ($bundleOptSelAttr != null) {
         $options['bundle_selection_attributes'] = $bundleOptSelAttr;
     }
     $finalPrice = $price;
     if ($product['parent_product_id']) {
         $productParent = Mage::getModel('catalog/product')->load($product['parent_product_id']);
         if ($productParent->getTypeID() == "bundle" && $productParent->getPriceType() == 0) {
             //GET PROC FROM REAL PRICE
             $priceModel = $productParent->getPriceModel();
             $PriceBundle = $priceModel->getTotalPrices($productParent, null, true, false);
             $PriceBundle = reset($PriceBundle);
             $priceProdCur = $product->getFinalPrice();
             $currPorc = 100 * $priceProdCur / $PriceBundle;
             $finalPrice = $currPorc * $price / 100;
         }
     }
     $qtdOrdered = $product['cart_qty'];
     if ($product->getTypeID() == "bundle") {
         $rowTotal = 0;
     } else {
         $rowTotal = $finalPrice * $qty;
     }
     $orderItem = Mage::getModel('sales/order_item')->setStoreId($this->_storeId)->setQuoteItemId(0)->setQuoteParentItemId(NULL)->setProductId($product->getId())->setProductType($product->getTypeId())->setQtyBackordered(NULL)->setTotalQtyOrdered($product['rqty'])->setQtyOrdered($qtdOrdered)->setName($product->getName())->setSku($product->getSku())->setPrice($finalPrice)->setBasePrice($finalPrice)->setOriginalPrice($product->getFinalPrice())->setRowTotal($rowTotal)->setBaseRowTotal($rowTotal)->setWeeeTaxApplied(serialize(array()))->setBaseWeeeTaxDisposition(0)->setWeeeTaxDisposition(0)->setBaseWeeeTaxRowDisposition(0)->setWeeeTaxRowDisposition(0)->setBaseWeeeTaxAppliedAmount(0)->setBaseWeeeTaxAppliedRowAmount(0)->setWeeeTaxAppliedAmount(0)->setWeeeTaxAppliedRowAmount(0)->setProductOptions($options);
     $this->_subTotal += $rowTotal;
     return $orderItem;
 }
开发者ID:AnyMarket,项目名称:magento,代码行数:54,代码来源:Ordergenerator.php

示例6: representProduct

 /**
  * Check product representation in item
  *
  * @param   Mage_Catalog_Model_Product $product
  * @return  bool
  */
 public function representProduct($product)
 {
     $itemProduct = $this->getProduct();
     if ($itemProduct->getId() != $product->getId()) {
         return false;
     }
     $itemOptions = $this->getOptions();
     $productOptions = $product->getCustomOptions();
     foreach ($itemOptions as $option) {
         $code = $option->getCode();
         if (in_array($code, $this->_notRepresentOptions)) {
             continue;
         }
         if (!isset($productOptions[$code]) || $productOptions[$code]->getValue() === null || $productOptions[$code]->getValue() != $option->getValue()) {
             return false;
         }
     }
     return true;
 }
开发者ID:jauderho,项目名称:magento-mirror,代码行数:25,代码来源:Item.php

示例7: isRepresentProduct

 /**
  * Check product representation in item
  *
  * @param   Mage_Catalog_Model_Product $product
  * @return  bool
  */
 public function isRepresentProduct($product)
 {
     if ($this->getProductId() != $product->getId()) {
         return false;
     }
     $productCustomOptions = $product->getCustomOptions();
     if (empty($productCustomOptions['info_buyRequest'])) {
         return false;
     }
     $requestOption = $productCustomOptions['info_buyRequest'];
     $requestArray = unserialize($requestOption->getValue());
     $selfOptions = unserialize($this->getCustomOptions());
     if (!$this->_compareOptions($requestArray, $selfOptions)) {
         return false;
     }
     if (!$this->_compareOptions($selfOptions, $requestArray)) {
         return false;
     }
     return true;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:26,代码来源:Item.php

示例8: array

 /**
  * add product in order
  *
  * @access protected
  * @param $product, $qty, $price
  * @return order object
  * 
  */
 function _productToOrderItem(Mage_Catalog_Model_Product $product, $qty = 1, $price)
 {
     if ($price) {
         $finalPrice = $price;
     } else {
         $finalPrice = $product->getFinalPrice();
     }
     $rowTotal = $finalPrice * $qty;
     $options = $product->getCustomOptions();
     $optionsByCode = array();
     foreach ($options as $option) {
         $quoteOption = Mage::getModel('sales/quote_item_option')->setData($option->getData())->setProduct($option->getProduct());
         $optionsByCode[$quoteOption->getCode()] = $quoteOption;
     }
     $product->setCustomOptions($optionsByCode);
     // DECREMENTE O STOCK
     $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
     if ($stockItem->getManageStock()) {
         $stockItem->setData('qty', $stockItem->getQty() - $product['qty']);
     }
     $stockItem->save();
     $options = $product->getTypeInstance(true)->getOrderOptions($product);
     $orderItem = Mage::getModel('sales/order_item')->setStoreId($this->_storeId)->setQuoteItemId(0)->setQuoteParentItemId(NULL)->setProductId($product->getId())->setProductType($product->getTypeId())->setQtyBackordered(NULL)->setTotalQtyOrdered($product['rqty'])->setQtyOrdered($product['qty'])->setName($product->getName())->setSku($product->getSku())->setPrice($finalPrice)->setBasePrice($finalPrice)->setOriginalPrice($finalPrice)->setRowTotal($rowTotal)->setBaseRowTotal($rowTotal)->setWeeeTaxApplied(serialize(array()))->setBaseWeeeTaxDisposition(0)->setWeeeTaxDisposition(0)->setBaseWeeeTaxRowDisposition(0)->setWeeeTaxRowDisposition(0)->setBaseWeeeTaxAppliedAmount(0)->setBaseWeeeTaxAppliedRowAmount(0)->setWeeeTaxAppliedAmount(0)->setWeeeTaxAppliedRowAmount(0)->setProductOptions($options);
     $this->_subTotal += $rowTotal;
     return $orderItem;
 }
开发者ID:novapc,项目名称:magento,代码行数:34,代码来源:Ordergenerator.php


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