Magento 1.9.2.1:单页结帐时未显示产品的颜色、尺寸属性

Magento 1.9.2.1: Color, size attribute of product not showing on onepage checkout

最近给商品颜色和尺码添加了属性。 (可配置产品) 当我们添加到购物车并查看购物车时,我们会看到具有颜色和尺寸属性的产品。

我在 app/design/frontend/smartwave/porto/layout/iwd_opc 的单页结帐中添加了购物车块。xml

<reference name="content">
        <block type="checkout/cart" name="checkout.cart" template="checkout/cart.phtml">
            <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
            <block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
            <block type="checkout/cart_sidebar" name="checkout.cart.sidebar" as="sidebar" template="checkout/cart/sidebar.phtml"/>
        </block>
    </reference>

将购物车布局添加到单页购物车后,我得到以下页面

现在我卡在这里了,我应该如何在这里获取属性名称? 我也将属性设置为在前端从后端可见。

在购物车中显示产品的代码在 app/design/frontend/smartwave/porto/template/checkout/cart.phtml

<?php foreach($this->getItems() as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php endforeach ?>

代码逻辑写到这里:app/code/core/Mage/Checkout/Block

public function getItems()
{
    if ($this->getCustomItems()) {
        return $this->getCustomItems();
    }

    return parent::getItems();
}

将产品显示到购物车的另一种方法是:但我不想使用此代码在购物车中显示列表:

$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
$productName = $item->getProduct()->getName();
$productPrice = $item->getProduct()->getPrice();

echo "Name: ".$productName." Price: ".$productPrice;
}

我也试过在xml文件中添加属性 app/code/core/Mage/Sales/etc/config.xml

            <item>
                <product_attributes>
                    <color/>
                    <size/> 
                    <condition/>
                    <sku/>
                    <type_id/>
                    <name/>
                    <status/>
                    <visibility/>
                    <price/>
                    <weight/>
                    <url_path/>
                    <url_key/>
                    <thumbnail/>
                    <small_image/>
                    <tax_class_id/>
                    <special_from_date/>
                    <special_to_date/>
                    <special_price/>
                    <cost/>
                    <is_recurring/>
                    <recurring_profile/>
                    <gift_message_available/>
                    <msrp_enabled/>
                    <msrp/>
                    <msrp_display_actual_price_type/>
                </product_attributes>
            </item>

所以我刚刚将该块复制到单页结帐页面,但我无法理解为什么单页结帐页面不显示产品的尺寸和颜色("/onepage/") 奇怪的是在结帐页面上可以看到颜色和尺码 ("checkout/cart/") 提前致谢

我相信您还没有在布局中添加 itemrendere。基本上使用 checkout/cart/item/default.phtml 列出购物车项目。

我建议查看 checkout.xml 布局文件并将整个布局 <reference name="content"> 节点复制到您的 iwd 中,然后开始删除您不需要的模板。

另一种方法是使用布局更新,这会将您的 iwd 布局扩展到 checkout_cart。这将在上面做同样的事情。您需要使用 <remove name=""> 标签从您的 iwd 手柄中删除额外的购物车。

最后我在 Blastfreak 的帮助下找到了解决方案 在 app/design/frontend/smartwave/porto/layout/iwd_opc.xml

中包含以下行
<reference name="content">
        <block type="checkout/cart" name="checkout.cart" template="checkout/cart.phtml">
            <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
            <block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
            <block type="checkout/cart_sidebar" name="checkout.cart.sidebar" as="sidebar" template="checkout/cart/sidebar.phtml"/>
            <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/item/default.phtml</template></action>
            <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/item/default.phtml</template></action>
            <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/item/default.phtml</template></action>
        </block>
    </reference>

输出页面: