Jump to content
Pat

[SOLVED] Jak přidat sloupec "Dopravce" pod TAB Objednavky v BO?

Recommended Posts

Zdravím,

 

nevíte někdo, jak přidat sloupec Dopravce do přehledu objednávek?

Zkoušel jsem to v adminXXXX/tabs/AdminOrders.php úpravou toho SQL dotazu, přidáním LEFT JOIN na tabulku carrier, ale stále my prestashop hlásil chybu v SQL dotazu.

Příp. nevíte někdo, jak by se dal ten vygenerovaný dotaz zobrazit, abych mohl zkoumat, kde tam mám chybu?

Máme prestashop 1.3.1.

Předem díky.

Edited by Pat (see edit history)

Share this post


Link to post
Share on other sites

Zdravím,

 

tak jsem si to vyřešil :)

Share this post


Link to post
Share on other sites
On 10/8/2014 at 8:47 AM, Pat said:

Zdravím,

 

tak jsem si to vyřešil :)

A mohu vědět jak? Mám PS 1.7.6 a nevím, jak jej přidat, resp. jak sloupec zavolat v AdminOrdersController.php

Share this post


Link to post
Share on other sites
On 3/17/2020 at 7:17 PM, Honya K. said:

A mohu vědět jak? Mám PS 1.7.6 a nevím, jak jej přidat, resp. jak sloupec zavolat v AdminOrdersController.php

Ptát se jak to udělat v Prestashopu 1.7 a chtít radu pro Prestashop 1.3 je nesmysl.

Od verze 1.3 do verze 1.7 je dlouhá cesta a mnoho změn.

Stejně jako by jsi opravoval letadlo a chtěl návod na opravu Trabanta.

 

A co takto!

Najít řádek 55 - 56 ...:

a.id_order AS id_pdf,

A pod něj přidat:

car.name AS carrier_name,

Najít řádek 69 - 70...:

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 . ')';

A změnit na:

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 . ')
LEFT JOIN `' . _DB_PREFIX_ . 'carrier` car ON (a.`id_carrier` = car.`id_carrier`)'; 

Najít řádek 98 - 99 ...:

'customer' => array(
                'title' => $this->trans('Customer', array(), 'Admin.Global'),
                'havingFilter' => true,
            ),

A pod něj přidat:

'carrier_name' => array(
                'title' => $this->trans('Carrier', array(), 'Admin.Global'),
                'havingFilter' => true,
            ),

Část upraveného kódu je:

public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'order';
        $this->className = 'Order';
        $this->lang = false;
        $this->addRowAction('view');
        $this->explicitSelect = true;
        $this->allow_export = true;
        $this->deleted = false;

        parent::__construct();

        $this->_select = '
		a.id_currency,
		a.id_order AS id_pdf,
    car.name AS carrier_name,
		CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
		osl.`name` AS `osname`,
		os.`color`,
		IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = a.id_customer AND so.id_order < a.id_order LIMIT 1) > 0, 0, 1) as new,
		country_lang.name as cname,
		IF(a.valid, 1, 0) badge_success';

        $this->_join = '
		LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON (c.`id_customer` = a.`id_customer`)
		INNER JOIN `' . _DB_PREFIX_ . 'address` address ON address.id_address = a.id_address_delivery
		INNER JOIN `' . _DB_PREFIX_ . 'country` country ON address.id_country = country.id_country
		INNER 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 . ')
    LEFT JOIN `' . _DB_PREFIX_ . 'carrier` car ON (a.`id_carrier` = car.`id_carrier`)';    
        $this->_orderBy = 'id_order';
        $this->_orderWay = 'DESC';
        $this->_use_found_rows = true;
        

        $statuses = OrderState::getOrderStates((int) $this->context->language->id);
        foreach ($statuses as $status) {
            $this->statuses_array[$status['id_order_state']] = $status['name'];
        }

        $this->fields_list = array(
            'id_order' => array(
                'title' => $this->trans('ID', array(), 'Admin.Global'),
                'align' => 'text-center',
                'class' => 'fixed-width-xs',
            ),
            'reference' => array(
                'title' => $this->trans('Reference', array(), 'Admin.Global'),
            ),
            'new' => array(
                'title' => $this->trans('New client', array(), 'Admin.Orderscustomers.Feature'),
                'align' => 'text-center',
                'type' => 'bool',
                'tmpTableFilter' => true,
                'orderby' => false,
            ),
            'customer' => array(
                'title' => $this->trans('Customer', array(), 'Admin.Global'),
                'havingFilter' => true,
            ),
            'carrier_name' => array(
                'title' => $this->trans('Carrier', array(), 'Admin.Global'),
                'havingFilter' => true,
            ),
        );

        if (Configuration::get('PS_B2B_ENABLE')) {
            $this->fields_list = array_merge($this->fields_list, array(
                'company' => array(
                    'title' => $this->trans('Company', array(), 'Admin.Global'),
                    'filter_key' => 'c!company',
                ),
            ));
        }

 

  • Thanks 1

Share this post


Link to post
Share on other sites

It works, perfect.
Thank you

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More