Magento中可以通过访问Url把产品加入购物车。
1 添加简单产品(Simple Product)
(1) 通过产品id:checkout/cart/add?product=[id]&qty=[qty]
(2) 通过产品sku:$cProd = Mage::getModel(\'catalog/product\'); $id = $cProd->getIdBySku(\"$sku\");
2 添加可配置产品(Configurable Product)
checkout/cart/add?product=[id]&qty=[qty]&super_attribute[attribute_id]=[attribute_id]&super_attribute[attribute_id]=attribute_id
其 中attribute_id是产品的super attribute所对应的attribute id
阅读全文>>
magento添加随机商品模块
13 September 2010 8:50 Monday by小屋 浏览(2049)
以下代码在magento1.4.1.0中运行没有什么问题。将代码放在产品详细页的任何位置,如view.phtml或者media.phtml 中。
<!--for show other product-->
<?php $categories = $_product->getCategoryIds(); ?>
<?php
$result = array();
foreach($categories as $cat_id) {
$category = Mage::getModel('catalog/category');
$category->load($cat_id);
$collection = $category->getProductCollection();
foreach ($collection as $product) {
$result[] = $product->getId();
}
}
?>
<div class="box-others-a
阅读全文>>