本文整理汇总了PHP中Mage_Sales_Model_Quote_Item::getOptionByCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Item::getOptionByCode方法的具体用法?PHP Mage_Sales_Model_Quote_Item::getOptionByCode怎么用?PHP Mage_Sales_Model_Quote_Item::getOptionByCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Item
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Item::getOptionByCode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compare
/**
* Compare item
*
* @param Mage_Sales_Model_Quote_Item $item
* @return bool
*/
public function compare($item)
{
if ($item->getOptionByCode('chili_document_id')) {
return false;
}
return parent::compare($item);
}
示例2: getBuyRequest
/**
* Use our own method to get buyRequest
* @param Mage_Sales_Model_Quote_Item $salesItem
* @return Varien_Object
*
*/
public function getBuyRequest($salesItem, $option = false)
{
if ($option) {
$option = $salesItem->getOptionByCode('info_buyRequest');
$buyRequest = new Varien_Object($option && $option->getValue() ? unserialize($option->getValue()) : null);
$buyRequest->setOriginalQty($buyRequest->getQty())->setQty($salesItem->getQty() * 1);
return $buyRequest;
}
$option = $salesItem->getProductOptionByCode('info_buyRequest');
if (!$option) {
$option = array();
}
$buyRequest = new Varien_Object($option);
$buyRequest->setQty($salesItem->getQtyOrdered() * 1);
return $buyRequest;
}
示例3: getProductId
/**
* Returns the product id for a quote item.
* Always try to find the "parent" product ID if the product is a child of
* another product type. We do this because it is the parent product that
* we tag on the product page, and the child does not always have it's own
* product page. This is important because it is the tagged info on the
* product page that is used to generate recommendations and email content.
*
* @param Mage_Sales_Model_Quote_Item $item the quote item model.
*
* @return int|string
*/
public function getProductId($item)
{
$parentItem = $item->getOptionByCode('product_type');
if (!is_null($parentItem)) {
return $parentItem->getProductId();
} elseif ($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());
$attributes = $item->getBuyRequest()->getData('super_attribute');
// 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 ID.
if (count($parentIds) === 1 && !empty($attributes)) {
return $parentIds[0];
}
}
return $item->getProductId();
}
示例4: getCustomOptions
/**
* Get Custom Options of item
*
* @param Mage_Sales_Model_Quote_Item $item
* @return array
*/
public function getCustomOptions(Mage_Sales_Model_Quote_Item $item)
{
$optionStr = '';
$this->_moveToCustomerStorage = true;
if ($optionIds = $item->getOptionByCode('option_ids')) {
foreach (explode(',', $optionIds->getValue()) as $optionId) {
if ($option = $item->getProduct()->getOptionById($optionId)) {
$optionValue = $item->getOptionByCode('option_' . $option->getId())->getValue();
$optionStr .= $option->getTitle() . ':';
$quoteItemOption = $item->getOptionByCode('option_' . $option->getId());
$group = $option->groupFactory($option->getType())->setOption($option)->setQuoteItemOption($quoteItemOption);
$optionStr .= $group->getEditableOptionValue($quoteItemOption->getValue());
$optionStr .= "\n";
}
}
}
return $optionStr;
}
示例5: compare
/**
* Compare item
*
* @param Mage_Sales_Model_Quote_Item $item
* @return bool
*/
public function compare($item)
{
if ($this->getProductId() != $item->getProductId()) {
return false;
}
foreach ($this->getOptions() as $option) {
if (in_array($option->getCode(), $this->_notRepresentOptions)) {
continue;
}
if ($itemOption = $item->getOptionByCode($option->getCode())) {
$itemOptionValue = $itemOption->getValue();
$optionValue = $option->getValue();
// dispose of some options params, that can cramp comparing of arrays
if (is_string($itemOptionValue) && is_string($optionValue)) {
$_itemOptionValue = @unserialize($itemOptionValue);
$_optionValue = @unserialize($optionValue);
if (is_array($_itemOptionValue) && is_array($_optionValue)) {
$itemOptionValue = $_itemOptionValue;
$optionValue = $_optionValue;
// looks like it does not break bundle selection qty
unset($itemOptionValue['qty'], $itemOptionValue['uenc'], $optionValue['qty'], $optionValue['uenc']);
}
}
if ($itemOptionValue != $optionValue) {
return false;
}
} else {
return false;
}
}
return true;
}
示例6: _prepareOptionsForRequest
/**
* Prepare options array for info buy request
*
* @param Mage_Sales_Model_Quote_Item $item
* @return array
*/
protected function _prepareOptionsForRequest($item)
{
$newInfoOptions = array();
if ($optionIds = $item->getOptionByCode('option_ids')) {
foreach (explode(',', $optionIds->getValue()) as $optionId) {
$option = $item->getProduct()->getOptionById($optionId);
$optionValue = $item->getOptionByCode('option_' . $optionId)->getValue();
$group = Mage::getSingleton('catalog/product_option')->groupFactory($option->getType())->setOption($option)->setQuoteItem($item);
$newInfoOptions[$optionId] = $group->prepareOptionValueForRequest($optionValue);
}
}
return $newInfoOptions;
}
示例7: compare
/**
* Compare item
*
* @param Mage_Sales_Model_Quote_Item $item
* @return bool
*/
public function compare($item)
{
if ($this->getProductId() != $item->getProductId()) {
return false;
}
foreach ($this->getOptions() as $option) {
if (in_array($option->getCode(), $this->_notRepresentOptions) && !$item->getProduct()->hasCustomOptions()) {
continue;
}
if ($itemOption = $item->getOptionByCode($option->getCode())) {
$itemOptionValue = $itemOption->getValue();
$optionValue = $option->getValue();
// dispose of some options params, that can cramp comparing of arrays
if (is_string($itemOptionValue) && is_string($optionValue)) {
try {
/** @var Unserialize_Parser $parser */
$parser = Mage::helper('core/unserializeArray');
$_itemOptionValue = $parser->unserialize($itemOptionValue);
$_optionValue = $parser->unserialize($optionValue);
if (is_array($_itemOptionValue) && is_array($_optionValue)) {
$itemOptionValue = $_itemOptionValue;
$optionValue = $_optionValue;
// looks like it does not break bundle selection qty
unset($itemOptionValue['qty'], $itemOptionValue['uenc']);
unset($optionValue['qty'], $optionValue['uenc']);
}
} catch (Exception $e) {
Mage::logException($e);
}
}
if ($itemOptionValue != $optionValue) {
return false;
}
} else {
return false;
}
}
return true;
}
示例8: getProductUrl
protected function getProductUrl(Mage_Sales_Model_Quote_Item $item)
{
if ($item->getRedirectUrl()) {
return $item->getRedirectUrl();
}
$product = $item->getProduct();
$option = $item->getOptionByCode('product_type');
if ($option) {
$product = $option->getProduct();
}
return $product->getUrlModel()->getUrl($product);
}
示例9: getCustomOptions
/**
* Get Custom Options of item
*
* @param Mage_Sales_Model_Quote_Item $item
* @return array
*/
public function getCustomOptions(Mage_Sales_Model_Quote_Item $item)
{
$optionStr = '';
$this->_moveToCustomerStorage = true;
if ($optionIds = $item->getOptionByCode('option_ids')) {
foreach (explode(',', $optionIds->getValue()) as $optionId) {
if ($option = $item->getProduct()->getOptionById($optionId)) {
$optionValue = $item->getOptionByCode('option_' . $option->getId())->getValue();
$optionStr .= $option->getTitle() . ':';
if ($option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX || $option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) {
foreach (explode(',', $optionValue) as $_value) {
$optionStr .= $option->getValueById($_value)->getTitle() . ', ';
}
$optionStr = Mage::helper('core/string')->substr($optionStr, 0, -2);
} elseif ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
$optionStr .= $option->getValueById($optionValue)->getTitle();
} else {
$optionStr .= $optionValue;
}
$optionStr .= "\n";
}
}
}
foreach ($item->getProduct()->getOptions() as $option) {
if ($option->getIsRequire() && !$item->getOptionByCode('option_' . $option->getId())) {
$optionStr .= $option->getTitle() . ':' . "\n";
}
}
if ($additionalOptions = $item->getOptionByCode('additional_options')) {
$this->_moveToCustomerStorage = false;
foreach (unserialize($additionalOptions->getValue()) as $additionalOption) {
$optionStr .= $additionalOption['label'] . ':' . $additionalOption['value'] . "\n";
}
}
$optionStr = $this->helper('core/string')->substr($optionStr, 0, -1);
return $optionStr;
}
示例10: _prepareOptionsForRequest
/**
* Prepare options array for info buy request
*
* @param Mage_Sales_Model_Quote_Item $item
* @return array
*/
protected function _prepareOptionsForRequest($item)
{
$newInfoOptions = array();
if ($optionIds = $item->getOptionByCode('option_ids')) {
foreach (explode(',', $optionIds->getValue()) as $optionId) {
$optionType = $item->getProduct()->getOptionById($optionId)->getType();
$optionValue = $item->getOptionByCode('option_' . $optionId)->getValue();
if ($optionType == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX || $optionType == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) {
$optionValue = explode(',', $optionValue);
}
$newInfoOptions[$optionId] = $optionValue;
}
}
return $newInfoOptions;
}
示例11: getSubscriptionOptionFromQuoteItem
/**
* @param Mage_Sales_Model_Quote_Item $quoteItem
* @return bool|array
*/
public function getSubscriptionOptionFromQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem)
{
$subscriptionOption = false;
$additionalOptions = $quoteItem->getOptionByCode('additional_options');
if ($quoteItem->getOptionByCode('additional_options')) {
$additionalOptions = unserialize($additionalOptions->getValue());
foreach ($additionalOptions as $option) {
if ($option['code'] == 'adyen_subscription') {
$subscriptionOption = $option;
break;
}
}
}
return $subscriptionOption;
}
示例12: getSimpleProductFromItemOptions
/**
* Retrieve simple product from cart item option.
*
* @param Mage_Sales_Model_Quote_Item $item
* @return Mage_Catalog_Model_Product|null
*/
public function getSimpleProductFromItemOptions(Mage_Sales_Model_Quote_Item $item)
{
$result = null;
if ($item) {
$o = $item->getOptionByCode('simple_product');
if ($o && $o->getProductId()) {
$result = Mage::getModel('catalog/product')->load($o->getProductId());
}
}
return $result;
}
示例13: _getGroupedOptions
/**
* Retrieves configuration options for grouped product
*
* @param Mage_Sales_Model_Quote_Item $item
* @return array
*/
protected function _getGroupedOptions($item)
{
$product = $item->getProduct();
$options = array();
/** @var $typeInstance Mage_Catalog_Model_Product_Type_Grouped */
$typeInstance = $product->getTypeInstance(true);
$associatedProducts = $typeInstance->getAssociatedProducts($product);
if ($associatedProducts) {
foreach ($associatedProducts as $associatedProduct) {
/** @var $associatedProduct Mage_Catalog_Model_Product */
$qty = $item->getOptionByCode('associated_product_' . $associatedProduct->getId());
$option = array('label' => $associatedProduct->getName(), 'value' => $qty && $qty->getValue() ? $qty->getValue() : 0);
$options[] = $option;
}
}
return array_merge($options, $this->_getCustomOptions($item));
}
示例14: _retrieveProductIdFromQuoteItem
/**
* Retrieve simple product id from quote item
*
* @param Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Quote_Address_Item $item
*
* @return int
*/
protected function _retrieveProductIdFromQuoteItem($item)
{
$productId = $item->getProductId();
if ($item->getOptionByCode('simple_product')) {
$productId = $item->getOptionByCode('simple_product')->getProduct()->getId();
}
return $productId;
}