Jump to content

Updating default product combination


Recommended Posts

Hi,

 

I started using Prestashop a few months ago. I have this problem, which I can't manage to solve:

 

I have a routine that regularly updates ps_stock_available with the actual quantities available for sale, and at the same time sets the default combination to the first combination having quantity >0 ("update ps_product_attribute set default_on=0 where id_product_attribute=3886..." and "update ps_product_attribute set default_on=1 where id_product_attribute=3895...").

 

Before the update:

 

mysql> select id_product_attribute,id_product,default_on from ps_product_attribute where id_product like '89588%' order by id_product_attribute ;
+----------------------+------------+------------+
| id_product_attribute | id_product | default_on |
+----------------------+------------+------------+
|                 3886 |  895880101 |          1 |
|                 3887 |  895880101 |          0 |
|                 3888 |  895880101 |          0 |
|                 3889 |  895880101 |          0 |
|                 3890 |  895880101 |          0 |
|                 3891 |  895880101 |          0 |
|                 3892 |  895880101 |          0 |
|                 3893 |  895880101 |          0 |
|                 3894 |  895880101 |          0 |
|                 3895 |  895880101 |          0 |
|                 3896 |  895880101 |          0 |
+----------------------+------------+------------+
11 rows in set (0.01 sec)
 

After the update, if I select data with mysql I find that the actual combination having default_on=1 is the one I updated with my procedure, as expected:

 

mysql> select id_product_attribute,id_product,default_on from ps_product_attribute where id_product like '89588%' order by id_product_attribute ;
+----------------------+------------+------------+
| id_product_attribute | id_product | default_on |
+----------------------+------------+------------+
|                 3886 |  895880101 |          0 |
|                 3887 |  895880101 |          0 |
|                 3888 |  895880101 |          0 |
|                 3889 |  895880101 |          0 |
|                 3890 |  895880101 |          0 |
|                 3891 |  895880101 |          0 |
|                 3892 |  895880101 |          0 |
|                 3893 |  895880101 |          0 |
|                 3894 |  895880101 |          0 |
                3895 |  895880101 |          1 |
|                 3896 |  895880101 |          0 |
+----------------------+------------+------------+
11 rows in set (0.01 sec)
 

However, when I go to the product combinations tab in Prestashop back office I still see as default combination the original default combination which was set when importing csv (combination 3886) and, of course, also in the front office shop.

 

If I set the default combination using the back office form, then it's correctly displayed, both in the product combinations tab and in the front office shop. In the database the records are still as they were after my manual update (combination 3895 having default_on=1).

 

I've already tried rebuilding products index and clearing cache, with no result.
 
So my assumption is that either "default_on" item in "ps_product_attribute" table is not the correct item to update, or that there is something else which needs to be updated, too.
 
I have hundreds of products and their quantities are updated several times a day, so I cannot do the update manually using the back office form.
 
Can anybody help?
 
Thanks.
 
PS: I'm using Prestashop 1.5.6.1
 
Link to comment
Share on other sites

I found out that also item "cache_default_attribute" of table "ps_product" should be updated with the new default attribute id. However even this doesn't change the situation: in back-office and front-office I still see as default the original default combination.

Link to comment
Share on other sites

I solved my problem.

 

Following tables/items must also be updated:

 

  • item "default_on" must be updated not only on table "ps_product_attribute", but also on table "ps_product_attribute_shop"
  • item "cache_default_attribute" must be updated not only on table "ps_product", but also on table "ps_product_shop"

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
×
×
  • Create New...