Jump to content

A simpler way to move product places in "home category". and why wont it work sometimes?


Recommended Posts

2 questions.

1. is there any easier way to change places of the products presented in the Home category?
As it is now the last product added (the newest) will offcourse be shown last, furthest down. To change that i can click on the litle arrow and the product can step up or down one step. But iw i wanna change many prods several steps this is gonna be time consuming and anoying. Anyone have a better idea of how to deal with that?

2. same topic. many times after creating a new product and i try to move it up a step or so, i get the error message "1 error Failed to update the position." and then after a while doing some other stuff i suddenly can move it. whats up with that? is it that product have not been updated soon enough in the DB or something similar?

Thanks for your time.
Peter

Link to comment
Share on other sites

  • 2 weeks later...

Thank you Tempomania, i had allmost given up on this, and i had not thought about looking in the french threads.



I will post this guys solution as a quote here so if any search for the same as i did they will be able to find it.

Also, i have not tested this yet and cannot say its working or not, but i would expect so since they marked the thread [sOLVED]


I hit this problem.

Using phpmyadmin look in ps_catgeory_product. For each category, there should be a set of id_product and position pairs, e.g. for id_category = 1, I had 6 entries with values of (id_product, position) of (10,0), (13,3), (14,4), (12,2), (11,1) and (15,4).

If the positions are not in strict monotonic sequence, e.g. 0,1,2,3,4,5... I think the updatePosition code cannot reorder the products and you get the error message.

I corrected it to read (10,0), (13,1), (14,5), (12,4), (11,3) and (15,2), and then I could reorder the products OK.

I assume the update code was interrupted at some time before it could complete an update operation. It should really detect the invalid position values and correct them as best it can [in this example by updating to (10,0), (13,3), (14,4), (12,2), (11,1) and (15,5)]. At least then the user could correct the order.

Hope this helps,
Brian



]And then next suggestion.[/size]


I have a fast patch for this bug:

Open the file classes/Product.php, find for this piece of code (about line 286):

       if (!$res = Db::getInstance()->ExecuteS('
       SELECT cp.`id_product`, cp.`position`, cp.`id_category` 
       FROM `'._DB_PREFIX_.'category_product` cp
       WHERE cp.`id_category` = '.intval(Tools::getValue('id_category')).' 
       ORDER BY cp.`position` '.(intval($way) ? 'ASC' : 'DESC')))



And reemplace for:

$valor = Tools::getValue('id_category');

     if ($valor==0)
      $valor = 1;

       if (!$res = Db::getInstance()->ExecuteS('
       SELECT cp.`id_product`, cp.`position`, cp.`id_category` 
       FROM `'._DB_PREFIX_.'category_product` cp
       WHERE cp.`id_category` = '.intval($valor).' 
       ORDER BY cp.`position` '.(intval($way) ? 'ASC' : 'DESC'))) 



The problems is that id_category is always 0 when is home and the select don't return rows because the home category is 1.

Backup your database before of testing this patch, for me work like a charm.




Thanx for the help finding this.

Best regards
Peter
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...