如何在Magento购物车页面中获取选择选项参数

如何在Magento购物车页面中获取选择选项参数,magento,magento-1.7,Magento,Magento 1.7,我有一个单一产品的多选项。如何获取购物车页面中的所有产品选项参数。请告知。购物车页面已在default.phtml页面中加载。此页面调用渲染器页面。我尝试了很多方法,但都没有成功。请告知 我可以在购物车控制器页面中打印configureaction() public function configureAction() { // Extract item and product to configure $id = (int) $this->getR

我有一个单一产品的多选项。如何获取购物车页面中的所有产品选项参数。请告知。购物车页面已在default.phtml页面中加载。此页面调用渲染器页面。我尝试了很多方法,但都没有成功。请告知

我可以在购物车控制器页面中打印configureaction()

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。请指导我。

您可以在quote对象的项目中获得它。例如:

$quote = Mage::getSingleton('checkout/session')->getQuote();
foreach ($quote->getAllVisibleItems() as $item) {
    print_r($item->getOptions());
}
$quote->getAllVisibleItems()
将返回包含购物车中项目信息的
Mage\u Sales\u Model\u quote\u Item
对象列表


您应该检查
Mage\u Sales\u Model\u Quote\u Item
类以了解更多详细信息。

您可以在Quote对象的items中获得它。例如:

$quote = Mage::getSingleton('checkout/session')->getQuote();
foreach ($quote->getAllVisibleItems() as $item) {
    print_r($item->getOptions());
}
$quote->getAllVisibleItems()
将返回包含购物车中项目信息的
Mage\u Sales\u Model\u quote\u Item
对象列表


您应该检查
Mage\u Sales\u Model\u Quote\u Item
class以了解更多详细信息。

您想在哪里显示这些选项?默认情况下,Magento在购物车页面中显示这些选项。您好@ndlinh我需要获取default.phtml页面或renderer.php页面正如我所说,Magento默认情况下在购物车页面中显示这些选项。如果您使用的是自定义主题,但没有看到,那么问题可能出在自定义主题中。您可以通过更改为使用默认主题进行检查。如果默认主题起作用,您应该检查自定义主题的
checkout.xml
布局文件,并与默认主题的
checkout.xml
进行比较。布局处理程序应该检查的是
checkout\u cart\u index
。您好,您是否在
checkout/cart/render/default.phtml
中尝试了
echo$\u item->getBuyRequest()->getProjectid()
。由于getProjectid不在我们的文件中,这怎么可能呢?您想在哪里显示这些选项?默认情况下,Magento在购物车页面中显示这些选项。您好@ndlinh我需要获取default.phtml页面或renderer.php页面正如我所说,Magento默认情况下在购物车页面中显示这些选项。如果您使用的是自定义主题,但没有看到,那么问题可能出在自定义主题中。您可以通过更改为使用默认主题进行检查。如果默认主题起作用,您应该检查自定义主题的
checkout.xml
布局文件,并与默认主题的
checkout.xml
进行比较。布局处理程序应该检查的是
checkout\u cart\u index
。您好,您是否在
checkout/cart/render/default.phtml
中尝试了
echo$\u item->getBuyRequest()->getProjectid()
。这是怎么可能的,因为getProjectid不在我们的文件中。