26. Magento 常用(1)
2015-12-09 16:25
204 查看
/article/3741723.html
众所周知,Magento的多店铺功能非常强大,通过多店铺功能,我们可以在一个Magento应用当中创建在外观上看来完全不相关联的多个店铺,并且可以绑定不同的域名。在Magento的开发当中,经常需要获取当前所在店铺的一些相关信息,例如店铺id,店铺名称及当前店铺所属Website的ID值。通过Magento的Mage类,我们可以获取到关于店铺的所有信息。
![](http://img.blog.csdn.net/20151213205401973)
![](http://img.blog.csdn.net/20151209160000931)
![](http://img.blog.csdn.net/20151209161741968)
![](http://img.blog.csdn.net/20151209161856654)
![](http://img.blog.csdn.net/20151209162004149)
![](http://img.blog.csdn.net/20151209162214446)
![](http://img.blog.csdn.net/20151209162328042)
2.获取配置文件的值
![](http://img.blog.csdn.net/20151209175016200)
![](http://img.blog.csdn.net/20151209175648891)
![](http://img.blog.csdn.net/20151209175654871)
配置文件中的值,都为下面类的元素:
![](http://img.blog.csdn.net/20151213211711613)
3. 创建基本类:
![](http://img.blog.csdn.net/20151217173200761)
![](http://img.blog.csdn.net/20151217173318530)
![](http://img.blog.csdn.net/20151217173403951)
![](http://img.blog.csdn.net/20151217173432508)
![](http://img.blog.csdn.net/20151217174414425)
![](http://img.blog.csdn.net/20151217175234632)
4.获取表名
![](http://img.blog.csdn.net/20151222150310367)
![](http://img.blog.csdn.net/20151222150317000)
众所周知,Magento的多店铺功能非常强大,通过多店铺功能,我们可以在一个Magento应用当中创建在外观上看来完全不相关联的多个店铺,并且可以绑定不同的域名。在Magento的开发当中,经常需要获取当前所在店铺的一些相关信息,例如店铺id,店铺名称及当前店铺所属Website的ID值。通过Magento的Mage类,我们可以获取到关于店铺的所有信息。
//获取所有商店信息 Mage::getModel('adminhtml/system_store')->getStoreCollection(); //获取所有,包括未激活的
//获取店铺对象 Mage::app()->getStore(); //获取激活的
//获取当前店铺ID Mage::app()->getStore()->getStoreId();
//获取当前店铺Code,该Code在创建店铺时填写 Mage::app()->getStore()->getCode();
//获取当前店铺所属的Website ID Mage::app()->getStore()->getWebsiteId();
//获取当前店铺的Name Mage::app()->getStore()->getName();
//获取当前店铺的状态 Mage::app()->getStore()->getIsActive();
//获取当前店铺的URL Mage::app()->getStore()->getHomeUrl();
2.获取配置文件的值
<?xml version="1.0"?> <config> <default> <some> <random> <xpath>Here is default</xpath> </random> </some> <catalog> <mypage> <name>myname</name> <age>100</age> <address>earth</address> </mypage> </catalog> </default> <stores> <french> <some> <random> <xpath>here is french store</xpath> </random> </some> </french> </stores> <global> <test1> <haha1>100</haha1> </test1> </global> <frontend> <test2> <haha2>200</haha2> </test2> </frontend> <admin> <test3> <haha3>300</haha3> </test3> </admin> </config>
Mage::getConfig()->getNode(绝对路径);
配置文件中的值,都为下面类的元素:
3. 创建基本类:
//1.创建 model Mage::getModel('uri'); //2.创建 helper Mage::helper('uri'); //3.创建 block Mage::app()->getLayout()->createBlock('uri); //4.手动创建block,设置模板 class Www_First_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $block = Mage::app()->getLayout() ->createBlock('core/template') ->setTemplate('first/first.phtml')->toHtml(); $this->getResponse()->setBody($block); } } 在 controller 中创建 block 也可以用 $this->getLayout()->createBlock('uri');
4.获取表名
相关文章推荐
- 将dicom的ct值归一到(0,255)
- Installing and Testing cygwin
- vs2010 EF4.0 访问mysql
- 15、MariaDB集群安装配置
- 线程
- Redis的Java客户端Jedis设计思路
- VisualVM无法运行提示找不到java
- tableViewcell自动调整高度
- byte 和 bit
- 加分二叉树
- 点击按钮控制div前后运动——定时器应用
- UTF-8 转 GBK
- HBase API 的使用(二)
- HBase API 的使用(一)
- ecshop 后台【左侧新增菜单】
- 【一】MongoDB安装及配置
- 【ITOO】NuGet发布类库包
- memcached 网络模型 --转载处:
- MacOS 多版本JDK切换
- CentOS下编写shell脚本来监控MySQL主从复制的教程