Thanks for your reply...
Your code works fine but erases all categories associated with the product, and i only wanna add or delete one the id_category 3470...
But this isn't the issue...Because your way or my way the results are fine in database (all OK)...
The problem is when this code runs (when stockOffVar is equal to Outlet50) should ended with this behavior:
-when you are in presta admin area, in product categories associated when you checked something new to associate then you must click in save button, and this is the only thing than i can't accomplish ...
I have an invisible category Outlet50 and some product are in, and in promotions catalogue i say all products in that category have 50% discount.
My website (prestashop) is populated by other logistics software and between both is another realtime synchronize api that connects prestashop database to logistics database.
So all my products and categories the origin is in logistics software, and prestashop orders at the end sync to the logistics...
So in my code that writes de category product from logistics to the prestashop database all works well, but in front (shop) my product doesn't shows 50% discount unless i go to the backoffice prestashop produc categories associations and click save button at the end...
Understand my issue?
Thank you all