giorinsrl Posted May 9, 2014 Share Posted May 9, 2014 Hi guys, i open a new topic because it's more clear and more useful for any user.i successful integrate a column with name category of product, but it print 6 times the name product, Why!?This is my AdminOrderController.php: $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`, a.`reference`, cl.`name` AS `cat_name`, IF((SELECT COUNT(so.id_order) FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new, GROUP_CONCAT(od.product_name separator \', \') as products'; $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 . ') LEFT JOIN `'._DB_PREFIX_. 'order_detail` od ON (od.id_order = a.id_order ) LEFT JOIN `'._DB_PREFIX_. 'product` p ON (p.id_product = od.product_id ) LEFT JOIN `'._DB_PREFIX_. 'category_lang` cl ON (p.id_category_default = cl.id_category )'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; $this->_group = 'GROUP BY a.id_order'; $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, ), //viewproductsoforder 'products' => array( 'title' => $this->l('Products'), 'align' => 'center', 'width' => 150, 'filter_key' => 'od!product_name' ), 'cat_name' => array( 'title' => $this->l('Categoria'), 'align' => 'center', 'width' => 100 ), 'gift' => array( 'title' => $this->l('Fattura'), 'havingFilter' => true, 'align' => 'center', 'icon' => array( 0 => 'blank.gif', 1 => array( 'src' => 'note.png', 'alt' => $this->l('Richiede Fattura'), ) ), 'width' => 35 ), '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); } Link to comment Share on other sites More sharing options...
UniqueModules Posted May 9, 2014 Share Posted May 9, 2014 (edited) find this IF((SELECT COUNT(so.id_order) FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new, GROUP_CONCAT(od.product_name separator \', \') as products'; change to (SELECT GROUP_CONCAT(so.product_name SEPARATOR "\ ") FROM `'._DB_PREFIX_.'order_detail` so WHERE so.id_order = a.id_order) as products, IF((SELECT COUNT(so.id_order) FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; Edited May 9, 2014 by UniqueModules (see edit history) Link to comment Share on other sites More sharing options...
UniqueModules Posted May 9, 2014 Share Posted May 9, 2014 Anyway here is nice tutorial from Nemops http://nemops.com/bought-products-prestashop-order-list/ Link to comment Share on other sites More sharing options...
giorinsrl Posted May 9, 2014 Author Share Posted May 9, 2014 Thank you so much..simply invert select count!Uaoo!!Thank you so much! 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