Jump to content

Change order of Colour picker, based on stock levels?


Recommended Posts

I'm finding myself in this situation a lot:


[Colour A - out of stock] [Colour B - out of stock] [Colour C - in stock]


Because there is no easy way in Prestashop to rearrange the colours, customers always think the Default A is out of stock so they never even bother checking C...so it sits there unsold!

Is there anyway to arrange this C, A, B...based on stock levels?


I tried changing the final line in Product.php from id_product_attribute to quantity, but that didn't seem to work:


   public function getAttributesGroups($id_lang)
   {
       return Db::getInstance()->ExecuteS('
       SELECT ag.`id_attribute_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name,
       a.`color` AS attribute_color, pa.`id_product_attribute`, pa.`quantity`, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`
       FROM `'._DB_PREFIX_.'product_attribute` pa
       LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
       LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute`
       LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group`
       LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute`
       LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group`
       WHERE pa.`id_product` = '.intval($this->id).'
       AND al.`id_lang` = '.intval($id_lang).'
       AND agl.`id_lang` = '.intval($id_lang).'
       ORDER BY pa.`quantity`');
   }

Link to comment
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...