Hello
I am trying to order products by SKU but I got it wrong The order is on the Order page (Checkout) This is a snippet of my code
$this->_items->getSelect()->order('main_table.sku ASC');$this->_items->getSelect()->group('main_table.item_id');
I am trying to order products having SKU : 4422; 00003001 and 00004335 but I am gotten them in this order :
4422
00003001
00004335
How can I solve this problem, don't hesitate if you need more details?
Thanks in advance!
Try this:
$this->_items->getSelect()->order('CAST(main_table.sku AS DECIMAL(10,2))
Hi @ahmed_chouihi
You can't get the SKU as ascending format as you mentioned, because SKU always a string type, not the integer type.
It will always treated as a string when you will try to sort by ascending.
I hope you got me concern.
It is incorrect I have written it like this and It is incorrect also :
$this->_items->getSelect()->order('CAST(main_table.sku AS DECIMAL(10,2)');
How can I solve it ?
Thanks in advance
Is there any other table having some order with Sku at least, because I must do that
Thanks