如何检查新功能是否在prestashop上工作



我是prestashop的新手,有一件事我不明白。

我需要添加一个函数来获得一个CSV文件,并将所有文件存储在一个数组中。该函数将被添加到该路径中的exixsting类中"/modules/devmanomano/classes/MyClass.php";现在我必须测试这个新函数,在类的末尾(在{}中(,我对我的object.method((进行了var_dump。当我在浏览器中查看文件地址时,我一无所获。(我走的是正确的路(。为什么?示例:

/modules/sdevmanomano/classes/MyClass.php
if (!defined('_PS_VERSION_')) {
exit;
}
include_once(dirname(__FILE__) . '/OtherClass.php');
class MyClass
{
...
//Before execute the code i want check if he has open correctly the CSV in tmpName
private function getDeliveryPrices(){
$tmpName = fopen(dirname(dirname(__FILE__)) . '/prices/prezzi_spedizione_francia.csv', 'r');
if ($tmpName){
$csvAsArray = 'ok';
} else {
$csvAsArray = 'errore';
}
return $csvAsArray;
}
}
// end of class
$test = new MyClass();
$res = $test->getDeliveryPrice();
var_dump($res);

通常在这一点上,在地址https:///modules/devmanomano/classes/MyClass.php我必须查看我的转储,但没有发生。为什么?

假设您想在模块上下文中的PrestaShop会话之外使用您的php脚本,以下是在独立的php脚本上需要PrestaShop配置的方法:

// /modules/sdevmanomano/classes/MyClass.php
/*
* Require the PrestaShop configuration
* relative to the location of this script
*/
reqire_once(dirname(__FILE__) . '../../../config/config.inc.php';
// Then you have access to _PS_VERSION_
if (!defined('_PS_VERSION_')) {
exit;
}

最新更新