Sunday, March 18, 2012

怎样增加magento顶部菜单


01 require 'app/Mage.php';  
02 Mage::app();  
04 $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');  
06 foreach ($products as $product) {  
07     if (!$product->hasImage()) continue;  
08     if (!$product->hasSmallImage()) $product->setSmallImage($product->getImage());  
09     if (!$product->hasThumbnail()) $product->setThumbnail($product->getImage());  
11     $product->save();
    magento一般按照默认的格式会自产生在导航菜单。例如默认主题中,我们可以看到导航菜单中得到的是我们的设置的后台的商品目录。下面我们来增加两个选项:主页和客户服务;
  定位到文件:安装目录:app/design/frontend/default/your theme/template/catalog/navigation/ 里面有一个文件:top.phtml;打开文件。(如果安装了其他主题可以到主题下的目录 )其中的主要内容是:
<?php //if(count($this->getStoreCategories())>1): ?>
    <ul id="nav">       <?php foreach ($this->getStoreCategories() as $_category): ?>           <?php echo $this->drawItem($_category) ?>       <?php endforeach ?>       </ul>   <?php //endif; ?>   两句需包含在 这对标签内。

  如果是想找向自己定义的cms page;
  可以将getUrl('customer-service') 里的customer-service改成是自己定义的cms page 的标识符(identifier)

1 comment: