产品货币无法使用,我在 Modx 系统中遇到错误
Product currency could not working, i getting error in Modx System
我用过Modx CMS。今天我收到这个错误。在我的错误行下面。
致命错误:在第 24 行 /var/www/bottega/core/cache/includes/elements/modsnippet/63.include.cache.php 中调用成员函数 get() 为空
$id = $row['id'];
$product = $modx->getObject('modResource', $id)->Product;
$price = $product->sm_price;
$currency = (int)$product->sm_currency; //$currency out is 153 dynamically
$currency = $modx->getObject('modResource', trim($currency))->get('longtitle'); //this line number 24
实际上,当我手动初始化 $currency
变量 153
时,这个问题就解决了。但是当我使用 $currency
从数据库 (int)$product->sm_currency;
初始化时它显示错误
Fatal error: Call to a member function get() on null in /var/www/bottega/core/cache/includes/elements/modsnippet/63.include.cache.php on line 24
例如$currency
变量手动初始化为153
$id = $row['id'];
$product = $modx->getObject('modResource', $id)->Product;
$price = $product->sm_price;
$currency = 153;
$currency = $modx->getObject('modResource', trim($currency))->get('longtitle'); //this line number 24
现在工作正常
这可能是由于您的托管公司更改了 PHP 版本所致。
由于您在问题中添加了一些代码:请在使用前检查对象是否存在(示例如下)。
$id = $row['id'];
$productRes = $modx->getObject('modResource', $id);
if ($productRes && $productRes->Product) {
$product = $productRes->Product;
$price = $product->sm_price;
$currency = (int)$product->sm_currency;
$currencyRes = $modx->getObject('modResource', $currency);
if ($currencyRes) {
$currency = currencyRes->get('longtitle');
}
}
我用过Modx CMS。今天我收到这个错误。在我的错误行下面。
致命错误:在第 24 行 /var/www/bottega/core/cache/includes/elements/modsnippet/63.include.cache.php 中调用成员函数 get() 为空
$id = $row['id'];
$product = $modx->getObject('modResource', $id)->Product;
$price = $product->sm_price;
$currency = (int)$product->sm_currency; //$currency out is 153 dynamically
$currency = $modx->getObject('modResource', trim($currency))->get('longtitle'); //this line number 24
实际上,当我手动初始化 $currency
变量 153
时,这个问题就解决了。但是当我使用 $currency
从数据库 (int)$product->sm_currency;
初始化时它显示错误
Fatal error: Call to a member function get() on null in /var/www/bottega/core/cache/includes/elements/modsnippet/63.include.cache.php on line 24
例如$currency
变量手动初始化为153
$id = $row['id'];
$product = $modx->getObject('modResource', $id)->Product;
$price = $product->sm_price;
$currency = 153;
$currency = $modx->getObject('modResource', trim($currency))->get('longtitle'); //this line number 24
现在工作正常
这可能是由于您的托管公司更改了 PHP 版本所致。
由于您在问题中添加了一些代码:请在使用前检查对象是否存在(示例如下)。
$id = $row['id'];
$productRes = $modx->getObject('modResource', $id);
if ($productRes && $productRes->Product) {
$product = $productRes->Product;
$price = $product->sm_price;
$currency = (int)$product->sm_currency;
$currencyRes = $modx->getObject('modResource', $currency);
if ($currencyRes) {
$currency = currencyRes->get('longtitle');
}
}