Magento:如何在CMS页面中包含php调用

Rad*_*duS 3 php call magento

按照此页面的说明操作:

http://www.magento.cc/how-to-use-php-on-a-cms-page.html

1)我在app/etc/modules中声明了模块:

<?xml version="1.0"?>
<config>
    <modules>
        <Stock_status>
            <active>true</active>
            <codePool>local</codePool>
</Stock_status>
</modules>
</config>
Run Code Online (Sandbox Code Playgroud)

2)然后我在app\code\local\Stock\status\Custom\etc中创建了config.xml,其中包含以下内容:

<?xml version="1.0"?>
<config>
<global>
<blocks>
<Stock_status>
<class>Stock_status_Block</class>
</Stock_status>
</blocks>
</global>
</config>
Run Code Online (Sandbox Code Playgroud)

3)之后我在app/code/local/Stock/status/Custom/Block文件中创建了一个test.php,其中包含以下内容:

<?php
class Stock_status_Block_Test extends Mage_Core_Block_Abstract
{
protected function _toHtml()
{
.Mage::helper('customstockstatus')->getListStatus($_product->getId()).
return $html;
}
}
Run Code Online (Sandbox Code Playgroud)

最后4)我进入了一个cms页面,通过将此值放入以下内容来查看它是否有效:

{{block type="Stock_status_Custom/test" ListStatus="02"}}
Run Code Online (Sandbox Code Playgroud)

这行代码应该返回特定产品的库存状态(在本例中,ID为02的产品)

但它不起作用.我做错了什么?有人可以帮帮我吗?

DRA*_*AJI 11

这些是不必要的工作,您可以通过将以下行添加到该cms页面内容中来简单地调用php文件

   {{block type="core/template" template="page/urfile.phtml"}}
Run Code Online (Sandbox Code Playgroud)

然后在页面目录下创建文件