prestasthop Collection与数据库连接



今天我有一些有趣的事情要做,我需要你的一些帮助。

我想加入PrestaShopCollection()与我在插件安装期间创建的数据库中的表。更具体地说,我创建了一个覆盖OrderCore和方法getOrderPaymentCollection(),我试图实现的是添加一个名为status的"列",我认为我可以做的是跟随

public function getOrderPaymentCollection()
{
    $order_payments = new PrestaShopCollection('OrderPayment');
    $order_payments->where('order_reference', '=', $this->reference);
    $order_payments->join(_DB_PREFIX_.'payment_table ppt','ppt.id_order = ' . $this->reference);
    return $order_payments;
}

可能有办法实现这一点吗?还是需要创建payment_table的集合?

谢谢!

这是一个非常古老的问题:)join()方法是有bug的,那么你不能这样做不是作为join()方法在DB类

你的代码应该是这样的:
public function getOrderPaymentCollection() 
{ 
    $order_payments = new PrestaShopCollection('OrderPayment');
    $order_payments->join('MyModulePaymentClass');
    $order_payments->where('order_reference', '=', $this->reference); 
    return $order_payments;
}

MyModulePaymentClass必须声明为ObjectModel不要忘记PrestashopCollection代码必须更新。因为在每种情况下都会引发异常。

最好使用DB::Query。

最新更新