国际电子商务技术 & Magento开发公司

Maishen technologies

Welcome visitor! You canlogin orcreate an account.

热线:+86-0532-58973093

麦神科技有限公司
Mygod Technologies

官方认证开发工程师

得到某一分类下面的所有子产品

2012年10月25日星期四 Asia/Shanghai下午2:55:05

得到某一分类下面的新产品,代码如下:

<?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); 







Read More
0 Comments | Posted in Magento开发 By terry water

得到某一分类的所有子分类,以及在子分类中新产品的个数

2012年10月25日星期四 Asia/Shanghai下午2:37:44

有一个需求,做出新产品页面,然后产品页面下面是所有的一级分类以及一级分类下面的新产品的个数。分享代码如下:

<?php
    //// top Seller
    if($_category->getName() == "New Arrivals"){
    echo '<div class="fuckyoufm">';
    $currid = 3;





Read More
0 Comments | Posted in Magento开发 By terry water

在magento中,获取子分类一般是2中:

1.得到某一个分类的下一级的分类,方法:

$currCat = Mage::getModel('catalog/category')->load($id) ; //当前分类
 
$collection = Mage::getModel('catalog/category')->getCategories($currCat->getEntityId());
得到一个包含所有一级子分类的对象。
2.得到当前分类的所有子分类(包括子分类的子分类)
方法:
$all_child_categories = $category_model->getResource()->getAllChildren($allcategory);
得到的所有子分类,包含父分类的所有分类的ID。
3.得到分类的所有产品的个数:
$tyr = Mage::getModel('catalog/category')->load($cate);
$tyr->getProductCount();
4.得到对象集合的个数,譬如产品集合中产品的个数
使用getSize()方法即可得到。
0 Comments | Posted in Magento开发 By terry water

得到产品页面url和分类页面url的后缀 -magento

2012年10月25日星期四 Asia/Shanghai上午11:54:12

得到分类页面的url后缀的代码为:

Mage::helper('catalog/category')->getCategoryUrlSuffix()

得到产品页面的url后缀的代码为:

 Mage::helper('catalog/product')->getProductUrlSuffix();

这样的话,通过产品的urlkey就可以直接得到产品的url了。

0 Comments | Posted in magento日常所用 By terry water

magento 得到当前分类的子分类

2012年10月24日星期三 Asia/Shanghai下午6:38:01

得到当前分类的子分类,具体的代码如下,可以快速的得到
<?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!
0 Comments | Posted in magento日常所用 By terry water
 
  • Mygod Technologies
  • 麦神科技有限公司
  • 香港中路8号
  • 中铁青岛中心大厦A3001
  • 市南区, 青岛, 266000
  • 电话: 0532-5897-3093

订阅我们的最新消息。

我们将严格尊重您的隐私。

关注我们的微信
获取外贸电子商务最新资讯;跨境推广最新策略;电子商务网站技术最新趋势。

2018 Mygod Technologies. 保留所有权. Privacy Policy