Magento是目前全球最高端的开源购物车系统平台,被ebay公司收购后,ebay技术团队强力介入,核心驱动不断得以完善升级。
Read MoreMagento的一些常用函数和功能
2012年5月28日星期一 Asia/Shanghai下午12:09:32
magento的一些常用的功能,小收集一下:
1
得到当前产品所在的分类代码:如下
<?php
$_cat = new Mage_Catalog_Block_Navigation();
$curent_cat = $_cat->getCurrentCategory();
$curent_cat_id = $curent_cat->getId();
echo $curent_cat_id;
?>
2
得到当前的分类:Mage::registry('current_category');
得到当前的产品:Mage::registry('current_product');
3
得到当前产品的属性:也就是在产品页面的加载的任何一个phtml文件都可以使用如下的方式获取产品的属性,方便做扩展
echo $currentproduct->getName();
echo $currentproduct->getId();
echo $currentproduct->getProductUrl();
echo $currentproduct->getSku();
echo $currentproduct->getAttributeText('attribute_name');
echo $this->helper('catalog/image')->init($currentproduct, 'small_image')->resize(100);
echo $currentcategory->getName();
echo $currentcategory->getId();
echo $currentcategory->getImageUrl();
echo $currentcategory->getUrl();
magento中通过产品的id得到产品的价格
2012年5月28日星期一 Asia/Shanghai上午11:23:11
magneto的价格方面是蛮强大的,有很多和打折相关的价格的设置
所以我们是不能和取到产品的名字那样直接 $_product->getName(),使用一个函数取到
需要查看价格的设置,来最终取到产品的最终价格。
最方便的方式是使用magento的里面的一个函数
$id = $this->getRequest()->getParam('id');
$product = Mage::getModel('catalog/product')->load($id);
echo $product->getFinalPrice();
即可得到产品的价格。
在很多页面一般都会有一个变量让您取到在该页面的id的,这样只需吧$id设置一下即可!
在您的网页上添加QQ的点击直接聊天代码
2012年5月28日星期一 Asia/Shanghai上午8:57:27
在自己的网店上添加网页在线直接聊天的QQ代码,之前有一个网址,现在换掉了,现在的网址为:http://wp.qq.com
点击后,开通服务,会给您一块代码,复制到自己的网站的即可。
在网上有一些文章,让把里面的代码中的QQ号码换成自己的号码的方式,这种是不能的,不能直接聊天,点击后需要加为好友才可以聊天,所以,这是一种服务,需要到上面这个网址中开通才可以使用这个服务。
开通后,可以让客户点击直接聊天,非常的方便,简洁,让您的网站过来更多的流量!
在magento菜单下加入一个静态块(static block)
2012年5月25日星期五 Asia/Shanghai上午8:36:14
magento1.6和1.7的版本有所不同
在magento1.6下
1
首先重写block class,找到/app/code/core/Mage/Catalog/Block/Navigation.php,复制到
/app/code/local/Mage/Catalog/Block/Navigation.php
2
找到方法: _renderCategoryMenuItemHtml
这个函数是画出菜单的方法
3
然后找到下面的代码的位置
$html
[] =
'<ul class="level'
.
$level
.
'">'
;
$html
[] =
$htmlChildren
;
$html
[] =
'</ul>'
;
$html
[] =
'<ul class="level'
.
$level
.
'">'
;
$html
[] =
$htmlChildren
;
$staticBlock
= trim(
$this
->getLayout()->createBlock(
'cms/block'
)->setBlockId(
strtolower
(
$category
->getUrlKey()))->toHtml());
if
(!
empty
(
$staticBlock
)){
$html
[] =
'<span class="nav-static-block" style="background:#fff; border-top:1px solid #ccc; padding:10px;">'
;
$html
[] =
$staticBlock
;
$html
[] =
'</span>'
;
}
$html
[] =
'</ul>'
;