【发布时间】:2015-12-20 18:13:25
【问题描述】:
最近我为产品颜色和尺寸添加了属性。 (可配置产品) 当我们添加到购物车并查看购物车时,我们会看到具有颜色和尺寸属性的产品。
我在 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 结帐页面,但我无法理解为什么 onepage 结帐页面没有显示产品的尺寸和颜色 ("/onepage/")奇怪的是,在结帐页面上可以看到颜色和尺寸 ("checkout/cart/") 提前致谢
【问题讨论】:
标签: magento magento-1.9