jorr19 Posted May 19, 2015 Share Posted May 19, 2015 Hi, I am wondering whether it is possible to change the ID of the attachments that determines what order they go in. We just have the option that we might be continually adding more attachments, and at the moment I have to remove the attachment from prestashop and reattach it later so I can have the correct order. Link to comment Share on other sites More sharing options...
shacker Posted May 25, 2015 Share Posted May 25, 2015 hi, why do you want ot change it? and wich order do you want? Link to comment Share on other sites More sharing options...
jorr19 Posted May 25, 2015 Author Share Posted May 25, 2015 hi, why do you want ot change it? and wich order do you want? Because when there is new products to add, I want it in a certain order, but because it sorts them into the order of the ID, it will put them in the wrong order. For example, I want an MP3 before a PDF. But if I've already uploaded the PDF, and then get my MP3 from my provider, then I can't just upload it because the MP3 will have a higher id number then the PDF. I have to remove the PDF, and then re-upload the MP3 before the PDF so that it's number will be lower. Eg, (MP3 might have an Id of 48, and the PDF'S ID might be 49. So it would put the MP3 first because it's ID is smaller...) Make sense? Link to comment Share on other sites More sharing options...
shacker Posted June 1, 2015 Share Posted June 1, 2015 open the classes/attachment.php you cna find the order here public static function getAttachments($id_lang, $id_product, $include = true) { return Db::getInstance()->executeS(' SELECT * FROM '._DB_PREFIX_.'attachment a LEFT JOIN '._DB_PREFIX_.'attachment_lang al ON (a.id_attachment = al.id_attachment AND al.id_lang = '.(int)$id_lang.') WHERE a.id_attachment '.($include ? 'IN' : 'NOT IN').' ( SELECT pa.id_attachment FROM '._DB_PREFIX_.'product_attachment pa WHERE id_product = '.(int)$id_product.' )' ); } You can add at the end a ORDER BY like public static function getAttachments($id_lang, $id_product, $include = true) { return Db::getInstance()->executeS(' SELECT * FROM '._DB_PREFIX_.'attachment a LEFT JOIN '._DB_PREFIX_.'attachment_lang al ON (a.id_attachment = al.id_attachment AND al.id_lang = '.(int)$id_lang.') WHERE a.id_attachment '.($include ? 'IN' : 'NOT IN').' ( SELECT pa.id_attachment FROM '._DB_PREFIX_.'product_attachment pa WHERE id_product = '.(int)$id_product.' ORDER BY id_product ASC )' ); } I set order by product ID asc, but you can order by any element of the table attachment 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