本文整理匯總了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;
}
示例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