簡體   English   中英

我在Magento的路線正確嗎?

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

我願意在magento的DATA.php中包含/要求一個文件。 我有代碼

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

    echo $Abowl;
     }

但這似乎並不起作用,因為當您使用require時,如果無法讀取文件,則執行將停止。

我的問題是如何獲取完整路徑並打印完整路徑以進行調試

更新1我試圖將die()函數應用到我的函數中,如下所示:

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

但是它仍然帶來錯誤並給出如下圖所示的結果:ps:我在Linux中找到的路徑: / var / www / html / app / design / frontend / neighborhood / default / template / catalog / category

在此處輸入圖片說明

順便說一下,我還有一個關於如何獲得$ price的附加問題?

檢查錯誤日志是否已啟用:

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

和apache日志。

對您的問題的要求是,如果找不到文件,它將一次中斷,因此您的問題是它不會被調用。 將骰子放在函數的頂部,以確保您可以進入內部:

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

    echo $Abowl;
     }

要輸出文件路徑,請運行以下命令:

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