我是stackoverflow的新手,但我会非常开放我怀疑和问题,我想问.
我试图在magento中创建一个自定义块.我是magento的新手并且学习它成为magento的高级开发人员.
我试过以下的事情:
我在magento/app/code/local/Magentotutorial中创建了一个目录Magentotutorial.
我在其中制作了一个基本结构,它是Magentotutorial中的五个目录.所以位置是magento/app/code/local/Magentotutorial/World
目录是:
magento/app/code/local/Magentotutorial/World/controllers,
magento/app/code/local/Magentotutorial/World/sql,
magento/app/code/local/Magentotutorial/World/Model,
magento/app/code/local/Magentotutorial/World/Helper,
magento/app/code/local/Magentotutorial/World/Block,
magento/app/code/local/Magentotutorial/World/etc.
Run Code Online (Sandbox Code Playgroud)
magento/app/code/local/Magentotutorial/World/etc/config.xmlconfig.xml文件包含以下代码:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Magentotutorial_World>
<version>0.1.0</version>
</Magentotutorial_World>
</modules>
<global>
<blocks>
<Magentotutorial_World>
<class>Magentotutorial_World_Block</class>
</Magentotutorial_World>
</blocks>
</global>
<frontend>
<layout>
<updates>
<Magentotutorial_World>
<file>test.xml</file>
</Magentotutorial_World>
</updates>
</layout>
</frontend>
</config>
Run Code Online (Sandbox Code Playgroud)
要在magento中激活我的模块,我创建了xml文件.
Magentotutorial_World.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Magentotutorial_World>
<active>true</active>
<codePool>local</codePool>
</Magentotutorial_World>
</modules>
</config>
Run Code Online (Sandbox Code Playgroud)
magento/app/code/local/Magentotutorial/World/Block
我已经创建了一个名为example.php的文件example.php具有以下代码:
<?php
class Magentotutorial_World_Block_Example extends Mage_Core_Block_Template
{
}
Run Code Online (Sandbox Code Playgroud)
5.现在我的magento目录中有布局和模板.magento/app/design/frontend/rwd/default/layout
在我的布局文件中,我创建了test.xml文件,其中包含以下代码:
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<block type="magentotutorial_world/example" name="newreferenceBlock" template="test/example.phtml" />
</default>
</layout> …Run Code Online (Sandbox Code Playgroud) 我正在尝试为以下sql进行elqouent查询,
select sum(w.total_item_count) as Day_count, w.created_at as created_at from `sales_flat_orders` as `w` group by DATE(`w`.`created_at`) order by `w`.`created_at` asc
Run Code Online (Sandbox Code Playgroud)
我试过这个
$orderbydate = DB::table('sales_flat_orders as w')
->select(array(DB::Raw('sum(w.total_item_count) as Day_count'),DB::Raw('DATE(w.created_at) as created_at')))
->groupBy('w.created_at')
->orderBy('w.created_at')
->get();
Run Code Online (Sandbox Code Playgroud)
我在sql查询中得到正确的输出,但没有在雄辩的查询中,请帮助,谢谢.