如何在Magento购物车页面中获取选择选项参数 [英] How to Get select option parameters in Magento Cart page
问题描述
我在单个产品中有多种选择.我如何在购物车页面中获取所有产品选项参数.请指教.购物车页面已在default.phtml页面中加载.此页面调用渲染器页面.我正在尝试许多方法,但无法正常工作.请告知
I have a multi option in single product. How can i get all the product option parameters in cart page. please advise. cart page already loading in default.phtml page. this page call to renderer page. i am trying many ways but not working. Please Advise
我可以在购物车控制器页面中打印configureaction()
i can print the configureaction() in Cart controller page
public function configureAction()
{
// Extract item and product to configure
$id = (int) $this->getRequest()->getParam('id');
$projectid = (int) $this->getRequest()->getParam('projectid');
$quoteItem = null;
$cart = $this->_getCart();
if ($id) {
$quoteItem = $cart->getQuote()->getItemById($id);
}
if (!$quoteItem) {
$this->_getSession()->addError($this->__('Quote item is not found.'));
$this->_redirect('checkout/cart');
return;
}
try {
$params = new Varien_Object();
$params->setCategoryId(false);
$params->setConfigureMode(true);
$params->setBuyRequest($quoteItem->getBuyRequest());
print_r($params);
我的参数列表
[_data:protected] => Array
(
[category_id] =>
[configure_mode] => 1
[buy_request] => Varien_Object Object
(
[_data:protected] => Array
(
[id] => 689
[product] => 288
[related_product] =>
[super_attribute] => Array
(
[143] => 65
[144] => 71
)
[options] => Array
(
[79] => 164
[80] => 167
[78] => 163
[81] => 169
)
[attachment_hash] => Array
(
[215] => 43f34b521ee06830bf462a4c060df869
)
[projectid] => 32
[qty] => 1
[reset_count] => 1
[original_qty] => 1
)
[_hasDataChanges:protected] => 1
[_origData:protected] =>
[_idFieldName:protected] =>
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
)
[_hasDataChanges:protected] => 1
[_origData:protected] =>
[_idFieldName:protected] =>
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
我需要在default.phtml页面或renderer.php页面中获取项目ID.请引导我.
I need to get project id in default.phtml page or renderer.php page. please guide me.
推荐答案
您可以在quote对象的项目中获取它.例如:
You can get it in items of quote object. For example:
$quote = Mage::getSingleton('checkout/session')->getQuote();
foreach ($quote->getAllVisibleItems() as $item) {
print_r($item->getOptions());
}
$quote->getAllVisibleItems()
将返回包含有关购物车中物品信息的Mage_Sales_Model_Quote_Item
对象列表.
$quote->getAllVisibleItems()
will return list of Mage_Sales_Model_Quote_Item
objects that contain informations about items in cart.
您应该检查Mage_Sales_Model_Quote_Item
类以了解更多详细信息.
You should check Mage_Sales_Model_Quote_Item
class for more details.
这篇关于如何在Magento购物车页面中获取选择选项参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!