如何在Prestashop 1.6后台列出没有分配地址的订单

时间:2016-11-25 07:27:56

标签: php mysql prestashop prestashop-1.6

我有一个prestashop,我已经修改了订购系统,其方式是不需要为订单分配地址。通过这种方式,地址字段的值为0。 问题是后台没有列出它,尽管所有数据都保存在数据库中。 我怎么能列出这些呢?也许我需要修改sql查询,但我不知道如何做到这一点以及如何。

1 个答案:

答案 0 :(得分:1)

address的左连接无法找到行,因为您将表id_address_delivery中的orders设置为0。

$this->_join = '
    LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
    LEFT JOIN `'._DB_PREFIX_.'address` address ON address.id_address = a.id_address_delivery
    LEFT JOIN `'._DB_PREFIX_.'country` country ON address.id_country = country.id_country
    LEFT JOIN `'._DB_PREFIX_.'country_lang` country_lang ON (country.`id_country` = country_lang.`id_country` AND country_lang.`id_lang` = '.(int)$this->context->language->id.')
    LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`)
    LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';

您可以使用模块挂钩修改此内容,然后使用actionControllerNameListingFieldsModifier生成列表以删除地址连接部分。

/*  AdminController getList() method

    Hook::exec('action'.$this->controller_name.'ListingFieldsModifier', array(
        'select' => &$this->_select,
        'join' => &$this->_join,
        'where' => &$this->_where,
        'group_by' => &$this->_group,
        'order_by' => &$this->_orderBy,
        'order_way' => &$this->_orderWay,
        'fields' => &$this->fields_list,
    ));
*/
public function hookActionAdminOrdersListingFieldsModifier($params) {
    // Remove address and country join clauses
    $params['join'] = '
    LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)       
    LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`)
    LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';
}