我们想修改prestashop中的订单参考逻辑,为此,我们实现了逻辑。逻辑很好。工作得很好,但我们收到一个错误
[PrestaShopException]
Property OrderPayment->order_reference length (14) must be between 0 and 9 at line 909 in file classes/ObjectModel.php
904. }
905.
906. $message = $this->validateField($field, $this->$field);
907. if ($message !== true) {
908. if ($die) {
909. throw new PrestaShopException($message);
910. }
911. return $error_return ? $message : false;
912. }
913. }
914.
我们的长度是30.如何将长度从9增加到30?
答案 0 :(得分:3)
您需要使用此文件OrderPayment
覆盖类/override/classes/order/OrderPayment.php
:
<?php
class OrderPayment extends OrderPaymentCore
{
public function __construct($id = null, $id_lang = null, $id_shop = null)
{
self::$definition['fields']['order_reference']['size'] = 30;
parent::__construct($id, $id_lang, $id_shop);
}
}
另外,您必须在phpmyadmin SQL选项卡中更新数据库order_reference字段大小:
ALTER TABLE `ps_order_payment`
CHANGE `order_reference`
`order_reference` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;