简体   繁体   English

我在Magento的路线正确吗?

[英]Am I getting the right path in Magento?

I am willing to include/require a file in DATA.php in magento. 我愿意在magento的DATA.php中包含/要求一个文件。 i have the code 我有代码

    public function formatPrice($price)
    {
require_once(Mage::getBaseDir('app').'\design\frontend\neighborhood\default\template\catalog\product\view.‌​phtml');

    echo $Abowl;
     }

But It doesn't seem like they are working, since when you use require the execution will be stop if can't read the file. 但这似乎并不起作用,因为当您使用require时,如果无法读取文件,则执行将停止。

My question is how to get the full path and print the full path out to debugged 我的问题是如何获取完整路径并打印完整路径以进行调试

UPDATE 1 I tried to apply the die() function into my function like this : 更新1我试图将die()函数应用到我的函数中,如下所示:

  public function formatPrice($price)
{
    die( 'here!' );
    require_once(Mage::getBaseDir('app').'/design/frontend/neighborhood/default/template/catalog/product/view.‌​phtml');
    echo $price;
}

But It bring error still and gives result as the image shows below: ps:the path i found in Linux : /var/www/html/app/design/frontend/neighborhood/default/template/catalog/category 但是它仍然带来错误并给出如下图所示的结果:ps:我在Linux中找到的路径: / var / www / html / app / design / frontend / neighborhood / default / template / catalog / category

在此处输入图片说明

By the way I have an additional question about how to get access to the $price? 顺便说一下,我还有一个关于如何获得$ price的附加问题?

Check your error logs if they are enabled: 检查错误日志是否已启用:

root/var/log/exception.log root/var/log/system.log root / var / log / exception.log root / var / log / system.log

And apache logs. 和apache日志。

On to your question require once will break if it cannot find the file so your issue is that it doesn't get called. 对您的问题的要求是,如果找不到文件,它将一次中断,因此您的问题是它不会被调用。 Place a die at the top of the function to ensure you can get inside: 将骰子放在函数的顶部,以确保您可以进入内部:

    public function formatPrice($price)
    {
die( 'here!' );
require_once(Mage::getBaseDir('app').'\design\frontend\neighborhood\default\template\catalog\product\view.‌​phtml');

    echo $Abowl;
     }

To output the file path run this: 要输出文件路径,请运行以下命令:

var_dump( Mage::getBaseDir('app').'\design\frontend\neighborhood\default\template\catalog\product\view.‌​phtml' );
die;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM