得到某一分类下面的新产品,代码如下:
<?php
$cat_id = 46; // category id
$category = Mage::getModel('catalog/category')->load($cat_id);
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
得到某一分类下面的新产品,代码如下:
<?php
$cat_id = 46; // category id
$category = Mage::getModel('catalog/category')->load($cat_id);
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
有一个需求,做出新产品页面,然后产品页面下面是所有的一级分类以及一级分类下面的新产品的个数。分享代码如下:
<?php
//// top Seller
if($_category->getName() == "New Arrivals"){
echo '<div class="fuckyoufm">';
$currid = 3;
在magento中,获取子分类一般是2中:
1.得到某一个分类的下一级的分类,方法:
$currCat =
Mage::getModel(
'catalog/category'
)->load($id)
; //当前分类
$collection
= Mage::getModel(
'catalog/category'
)->getCategories(
$currCat
->getEntityId());
得到分类页面的url后缀的代码为:
Mage::helper('catalog/category')->getCategoryUrlSuffix()
得到产品页面的url后缀的代码为:
Mage::helper('catalog/product')->getProductUrlSuffix();
这样的话,通过产品的urlkey就可以直接得到产品的url了。
<?php
$category_model
= Mage::getModel(
'catalog/category'
);
//get category model
$_category
=
$category_model
->load(
$categoryid
);
//$categoryid for which the child categories to be found
$all_child_categories
=
$category_model
->getResource()->getAllChildren(
$_category
);
//array consisting of all child categories id
?>
$all_child_categorie里面含有当前分类和所有子分类的ID,他是一个数组,OK!