Magento 常用代码笔记

作者:Jeen 发布于:2013-4-21 19:53 Sunday 分类:工作笔记

<?php

//输出对象相关信息,类 方法  值 等

请参考 参考上一篇文章   function objInfo() {}

//基础信息 $mage_obj

$mage_obj = new Mage();

//调用后台静态块

echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘block_id’)->toHtml();

echo $mage_obj->app()->getLayout()->createBlock(‘cms/block’)->setBlockId(‘block_id’)->toHtml();

 

//创建一个静态块

echo $mage_obj->getBlockSingleton(‘checkout/cart_sidebar’)->setTemplate(“checkout/cart/top_bar.phtml”)->toHtml();

echo $mage_obj->app()->getLayout()->getBlockSingleton(‘checkout/cart_sidebar’)->setTemplate(“checkout/cart/top_bar.phtml”)->toHtml();

 

//调用后台设置信息 //通常位于system.xml配置文件中

Mage::getStoreConfig(‘wjtheme/template/prodnav’);

//调用后台自定义变量值

Mage::getModel(‘core/variable’)->loadByCode(‘var_code’)->getValue();

//getSingleton 方法

objInfo($mage_obj->getSingleton(‘catalog/session’));

//getData() —last_visited_category_id   last_viewed_category_id   last_viewed_product_id

 

//helper  方法

Mage::helper(‘catalog/product’)

objInfo($mage_obj->helper(‘catalog/product’)->getEmailToFriendUrl($_product));

 

//getModel 方法

Mage::getModel(‘catalog/product’)

objInfo($mage_obj->getModel(‘catalog/product’)->load($product_id)->getProductUrl());

 

//registry 方法

Mage::registry(‘current_product’)

objInfo($mage_obj->registry(‘current_product’)->getId());

 

待补充…

标签: magento

发表评论:

©2010-2024 Jeen All Rights Reserved.Powered by emlog 京ICP备15058100号-1