Viktorin Posted April 24, 2014 Share Posted April 24, 2014 Добрый день всем. Имею потребность в выводе способа доставки который выбрал человек на странице таблицы заказов. В AdminOrdersController.php нашел как добавить вывод ида курьера в столбец таблицы, однако не могу решить вопрос, как следует сделать так, чтобы эти иды менялись на текст. Link to comment Share on other sites More sharing options...
Dzianis Yurevich Posted April 25, 2014 Share Posted April 25, 2014 В этом файле (AdminOrdersController.php), в конструкторе, перед строчкой parent::__construct() (строка 145), нужно вставить вот этот код: $this->_select .= ', ocl.`name` as `carrier_name`'; $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'order_carrier` oc ON (a.`id_order` = oc.`id_order`) LEFT JOIN `'._DB_PREFIX_.'carrier` ocl ON (oc.`id_carrier` = ocl.`id_carrier`) '; $this->fields_list['carrier_name'] = array( 'title' => $this->l('Carrier: '), 'width' => 100 ); И будет счастье) Link to comment Share on other sites More sharing options...
Viktorin Posted April 25, 2014 Author Share Posted April 25, 2014 В этом файле (AdminOrdersController.php), в конструкторе, перед строчкой parent::__construct() (строка 145), нужно вставить вот этот код: $this->_select .= ', ocl.`name` as `carrier_name`'; $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'order_carrier` oc ON (a.`id_order` = oc.`id_order`) LEFT JOIN `'._DB_PREFIX_.'carrier` ocl ON (oc.`id_carrier` = ocl.`id_carrier`) '; $this->fields_list['carrier_name'] = array( 'title' => $this->l('Carrier: '), 'width' => 100 ); И будет счастье) Неверный SQL запросColumn 'id_carrier' in field list is ambiguous Link to comment Share on other sites More sharing options...
Dzianis Yurevich Posted April 25, 2014 Share Posted April 25, 2014 Убери все свои предыдущие правки. Вот весь конструктор: public function __construct() { $this->table = 'order'; $this->className = 'Order'; $this->lang = false; $this->addRowAction('view'); $this->explicitSelect = true; $this->allow_export = true; $this->deleted = false; $this->context = Context::getContext(); $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_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.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; $statuses_array = array(); $statuses = OrderState::getOrderStates((int)$this->context->language->id); foreach ($statuses as $status) $statuses_array[$status['id_order_state']] = $status['name']; $this->fields_list = array( 'id_order' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 25 ), 'reference' => array( 'title' => $this->l('Reference'), 'align' => 'center', 'width' => 65 ), 'new' => array( 'title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'tmpTableFilter' => true, 'icon' => array( 0 => 'blank.gif', 1 => array( 'src' => 'note.png', 'alt' => $this->l('First customer order'), ) ), 'orderby' => false ), 'customer' => array( 'title' => $this->l('Customer'), 'havingFilter' => true, ), 'total_paid_tax_incl' => array( 'title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'type' => 'price', 'currency' => true ), 'payment' => array( 'title' => $this->l('Payment: '), 'width' => 100 ), 'osname' => array( 'title' => $this->l('Status'), 'color' => 'color', 'width' => 280, 'type' => 'select', 'list' => $statuses_array, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int' ), 'date_add' => array( 'title' => $this->l('Date'), 'width' => 130, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add' ), 'id_pdf' => array( 'title' => $this->l('PDF'), 'width' => 35, 'align' => 'center', 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false, 'remove_onclick' => true) ); $this->shopLinkType = 'shop'; $this->shopShareDatas = Shop::SHARE_ORDER; if (Tools::isSubmit('id_order')) { // Save context (in order to apply cart rule) $order = new Order((int)Tools::getValue('id_order')); if (!Validate::isLoadedObject($order)) throw new PrestaShopException('Cannot load Order object'); $this->context->cart = new Cart($order->id_cart); $this->context->customer = new Customer($order->id_customer); } $this->_select .= ', ocl.`name` as `carrier_name`'; $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'order_carrier` oc ON (a.`id_order` = oc.`id_order`) LEFT JOIN `'._DB_PREFIX_.'carrier` ocl ON (oc.`id_carrier` = ocl.`id_carrier`) '; $this->fields_list['carrier_name'] = array( 'title' => $this->l('Carrier: '), 'width' => 100 ); parent::__construct(); } 1 Link to comment Share on other sites More sharing options...
Viktorin Posted April 25, 2014 Author Share Posted April 25, 2014 Убери все свои предыдущие правки. Вот весь конструктор: public function __construct() { $this->table = 'order'; $this->className = 'Order'; $this->lang = false; $this->addRowAction('view'); $this->explicitSelect = true; $this->allow_export = true; $this->deleted = false; $this->context = Context::getContext(); $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_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.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; $statuses_array = array(); $statuses = OrderState::getOrderStates((int)$this->context->language->id); foreach ($statuses as $status) $statuses_array[$status['id_order_state']] = $status['name']; $this->fields_list = array( 'id_order' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 25 ), 'reference' => array( 'title' => $this->l('Reference'), 'align' => 'center', 'width' => 65 ), 'new' => array( 'title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'tmpTableFilter' => true, 'icon' => array( 0 => 'blank.gif', 1 => array( 'src' => 'note.png', 'alt' => $this->l('First customer order'), ) ), 'orderby' => false ), 'customer' => array( 'title' => $this->l('Customer'), 'havingFilter' => true, ), 'total_paid_tax_incl' => array( 'title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'type' => 'price', 'currency' => true ), 'payment' => array( 'title' => $this->l('Payment: '), 'width' => 100 ), 'osname' => array( 'title' => $this->l('Status'), 'color' => 'color', 'width' => 280, 'type' => 'select', 'list' => $statuses_array, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int' ), 'date_add' => array( 'title' => $this->l('Date'), 'width' => 130, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add' ), 'id_pdf' => array( 'title' => $this->l('PDF'), 'width' => 35, 'align' => 'center', 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false, 'remove_onclick' => true) ); $this->shopLinkType = 'shop'; $this->shopShareDatas = Shop::SHARE_ORDER; if (Tools::isSubmit('id_order')) { // Save context (in order to apply cart rule) $order = new Order((int)Tools::getValue('id_order')); if (!Validate::isLoadedObject($order)) throw new PrestaShopException('Cannot load Order object'); $this->context->cart = new Cart($order->id_cart); $this->context->customer = new Customer($order->id_customer); } $this->_select .= ', ocl.`name` as `carrier_name`'; $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'order_carrier` oc ON (a.`id_order` = oc.`id_order`) LEFT JOIN `'._DB_PREFIX_.'carrier` ocl ON (oc.`id_carrier` = ocl.`id_carrier`) '; $this->fields_list['carrier_name'] = array( 'title' => $this->l('Carrier: '), 'width' => 100 ); parent::__construct(); } премного благодарен. Еще вопрос, есть, если не сильно отвлекаю. Я вообще новичек в этом деле и не совсем понимаю откуда берется перевод. Знаю есть файлы с переводами, но переводы привязаны к ключам, а не к словам. К примеру: в том коде, что ты скинул Carrier: у меня не переводит, но переводит если написать Shipping. В локализации тоже смотрел и так же не понял откуда берется перевод. Как к примеру добавить фразу carrier, чтобы она переводила на русском? Link to comment Share on other sites More sharing options...
Dzianis Yurevich Posted April 25, 2014 Share Posted April 25, 2014 Фразы переводятся в Локализация - Переводы. Подробнее об переводах можно почитать например здесь: http://prestashop.wikia.com/wiki/Languages_and_Translations Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now