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


PHP unknown_type::getProduct方法代码示例

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


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

示例1: _locatedProductId

 /**
  * Attempts to retreive a product ID from the observer or the previously dispatch observer.
  * @param unknown_type $observer
  */
 protected function _locatedProductId($observer)
 {
     $target_product_id = null;
     $event = $observer->getEvent();
     $action = $observer->getControllerAction();
     if ($action) {
         $request = $action->getRequest();
         $target_product_id = $request->getParam("id");
         if (!$target_product_id) {
             $target_product_id = null;
         }
         //if no product id available, reset our assumption because this must be some other unrecognized request.
     }
     $product = $observer->getProduct();
     if (empty($product) && $event instanceof Varien_Event) {
         $product = $event->getProduct();
     }
     if ($product) {
         $target_product_id = $product->getEntityId();
         if (!$target_product_id) {
             $target_product_id = null;
         }
     }
     if ($target_product_id) {
         // IF a product ID was fetched, set it into the registry
         if (Mage::registry('rewards_catalogrule_apply_product_id_memory')) {
             Mage::unregister('rewards_catalogrule_apply_product_id_memory');
         }
         Mage::register('rewards_catalogrule_apply_product_id_memory', $target_product_id);
     } else {
         // IF a product ID was NOT fetched, attempt to get it from the registry
         if (Mage::registry('rewards_catalogrule_apply_product_id_memory')) {
             $target_product_id = Mage::registry('rewards_catalogrule_apply_product_id_memory');
             // After pulling it from the registry, remove it from the registry so the next immediate action does not recall this.
             Mage::unregister('rewards_catalogrule_apply_product_id_memory');
         }
     }
     return $target_product_id;
 }
开发者ID:rajarshc,项目名称:Rooja,代码行数:43,代码来源:Product.php

示例2: _addQuoteItemOption

 /**
  * Enter description here ...
  * @param unknown_type $quoteItem
  * @param unknown_type $optionCode
  * @param unknown_type $id
  * @return Emjainteractive_Advancedoptions_Model_Checkout_Cart_Observer
  */
 protected function _addQuoteItemOption($quoteItem, $optionCode, $id, $value)
 {
     $product = $quoteItem->getProduct();
     $productOption = $product->getOptionById($id);
     if ($productOption) {
         $quoteItemOption = Mage::getModel('sales/quote_item_option')->setItemId($quoteItem->getId())->setItem($quoteItem)->setProductId($product->getId())->setProduct($product)->setCode($optionCode)->setValue($value)->save();
         $quoteItem->addOption($quoteItemOption);
         $optionIdsItem = $quoteItem->getOptionByCode('option_ids');
         if (!$optionIdsItem) {
             $optionIdsItem = $this->_createQuoteOptionIdsItem($quoteItem);
         }
         $optionIds = $optionIdsItem->getValue();
         $optionIds = explode(',', $optionIds);
         $optionId = array_search($id, $optionIds);
         if (!$optionId) {
             $optionIds[] = $id;
             $optionIds = implode(',', $optionIds);
             $optionIdsItem->setValue($optionIds);
         }
     }
     return $this;
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:29,代码来源:Emjainteractive_Advancedoptions_Model_Checkout_Cart_Observer_ori.php

示例3: _addQuoteItemOption

 /**
  * Enter description here ...
  * @param unknown_type $quoteItem
  * @param unknown_type $optionCode
  * @param unknown_type $id
  * @return Emjainteractive_Advancedoptions_Model_Checkout_Cart_Observer
  */
 protected function _addQuoteItemOption($quoteItem, $optionCode, $id, $value)
 {
     $product = $quoteItem->getProduct();
     $productOption = $product->getOptionById($id);
     if ($productOption) {
         $quoteItemOption = Mage::getModel('sales/quote_item_option')->setItemId($quoteItem->getId())->setItem($quoteItem)->setProductId($product->getId())->setProduct($product)->setCode($optionCode)->setValue($value)->save();
         $quoteItem->addOption($quoteItemOption);
         $optionIdsItem = $quoteItem->getOptionByCode('option_ids');
         if (!$optionIdsItem) {
             $optionIdsItem = $this->_createQuoteOptionIdsItem($quoteItem);
             //$a = $quoteItem->getOption();
             //print_r($value);
             //exit;
             $write = Mage::getSingleton('core/resource')->getConnection('core_write');
             $read = Mage::getSingleton('core/resource')->getConnection('core_read');
             $tableName = Mage::getSingleton('core/resource')->getTableName('cart_customoption_update_status');
             $sessionId = Mage::getModel("core/session")->getEncryptedSessionId();
             $itemId = $quoteItem->getId();
             $optionId = $id;
             $query = "SELECT id FROM " . $tableName . " WHERE session_id = '" . $sessionId . "' AND item_id = '" . $itemId . "' AND option_id = '" . $optionId . "'";
             $itemIdExist = $read->fetchOne($query);
             if ($itemIdExist == "") {
                 $write->query("INSERT INTO " . $tableName . "  SET session_id='" . $sessionId . "',item_id='" . $itemId . "',option_id='" . $optionId . "'");
             }
             foreach ($product->getOptions() as $o) {
                 $productOptionId = $o->getId();
                 if ($productOptionId == $id) {
                     $totalOptionPrice = 0;
                     $values = $o->getValues();
                     foreach ($values as $k => $v) {
                         if ($v['option_type_id'] == $value) {
                             $totalOptionPrice += $v['price'];
                         }
                     }
                 }
             }
             $store = $product->getStore();
             $productItemPrice = $quoteItem->getProduct()->getPrice();
             $new_price = $productItemPrice + $totalOptionPrice;
             $productItemNewPrice = $store->convertPrice($new_price, false, false);
             $quoteItem->setOriginalCustomPrice($productItemNewPrice);
             $quoteItem->save();
         }
         $optionIds = $optionIdsItem->getValue();
         $optionIds = explode(',', $optionIds);
         $optionId = array_search($id, $optionIds);
         if (!$optionId) {
             $optionIds[] = $id;
             $optionIds = implode(',', $optionIds);
             $optionIdsItem->setValue($optionIds);
         }
     }
     return $this;
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:61,代码来源:Emjainteractive_Advancedoptions_Model_Checkout_Cart_Observer.php


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