在 Prestashop 客户视图中显示产品组合
Display Product Combinations in Prestashop Customer View
除了为客户显示的产品之外,我正在尝试让 Prestashop 管理 Customer
详细视图中显示的产品组合。
这似乎是 AdminCustomersController.php
在 public form renderForm()
中的相关调用:
$products = $customer->getBoughtProducts();
然后在Customer
class中找到了方法:
public function getBoughtProducts()
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT * FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
WHERE o.valid = 1 AND o.`id_customer` = '.(int)$this->id);
}
如何修改此方法以在产品名称旁边显示产品组合?
我正在使用 Prestashop 版本 1.6.0.9
。
您可以通过两种方式获得它:
order_detail
table 已经有字段 'product_name' 包含类似 'Product Name - Combination' 的值,因此您可以在这种情况下使用 $products['product_name']
。
或
- 如果由于某种原因它对你不利,同样的 table 也包含
product_attribute_id
字段,它是组合 ID,所以:
$combination = new Combination($product['product_attribute_id']);
$attributes = $combination->getAttributesName($id_lang);
var_dump($attributes);
将为您提供当前组合包含的属性数组。
除了为客户显示的产品之外,我正在尝试让 Prestashop 管理 Customer
详细视图中显示的产品组合。
这似乎是 AdminCustomersController.php
在 public form renderForm()
中的相关调用:
$products = $customer->getBoughtProducts();
然后在Customer
class中找到了方法:
public function getBoughtProducts()
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT * FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
WHERE o.valid = 1 AND o.`id_customer` = '.(int)$this->id);
}
如何修改此方法以在产品名称旁边显示产品组合?
我正在使用 Prestashop 版本 1.6.0.9
。
您可以通过两种方式获得它:
order_detail
table 已经有字段 'product_name' 包含类似 'Product Name - Combination' 的值,因此您可以在这种情况下使用$products['product_name']
。
或
- 如果由于某种原因它对你不利,同样的 table 也包含
product_attribute_id
字段,它是组合 ID,所以:
$combination = new Combination($product['product_attribute_id']);
$attributes = $combination->getAttributesName($id_lang);
var_dump($attributes);
将为您提供当前组合包含的属性数组。