Jump to content

invoice API - Auto-update stock to products with atributes


Recommended Posts

Hello, 

I have this invoice program called Keyinvoice, their API already updates the stock on "simple products" but im trying to configure it to add stock to products with combinations.
I dont want it to create new combinations, just want it to updade the stock on already existing ones.

Example: Product1 from keyinvoice has stock:1
Product1 from prestashop, with color red change the stock to 1.

This is the code that lets me update the stock on products without combinations

if ($kproduct->HasStocks)
                {
                    StockAvailable::setQuantity($product->id, 0, $kproduct->Stock);
                }

 

Any help?

Link to comment
Share on other sites

I have one issue with two ways to aproach it,
Change the code of an API, or configure a module with a Filter (without atributes).

Thats why i opened 2 threads, because i have 2 diferent questions. If i find a solution for one of the threads the other problem might be solved.

"An id_product_attribute that is 0 is the sum of all id_product_attributes for that product" I get this, this is why the code only edits stock for simple products.

My issue is, how can i code this to edit the stock inside the combination?

Or

Do you have any solution for the Filter module thread? 

Link to comment
Share on other sites

In the export, it can send attributes in the options tag. And why can't you send them in the import as well? Why use a service that can basically do 50%? I'm sorry, but I can't help you with that, because s3 would go against the logic of the warehouse in Prestashop. Can't be bypassed.

Link to comment
Share on other sites

I suspected it couldnt be done this way.
Do you know if there is a way to code the product attributes stock in prestashop to always show the same value as the product stock?

Lets say i export from keyinvoice the product without attributes with product id "1234" with the Stock of 10un
I import it to Prestashop, it will check the product ID and if it exists, updates the product stock.

If i can get the attribute stock to be the same as the product stock, my problem would be (kind of) solved.

Do you think it could be done?

Link to comment
Share on other sites

Hi.

Yes, I have already programmed such a solution or module for my customer. It included the option to choose in the product settings whether the attributes should be calculated and matched as a separate product.

Compatible with Prestashop 1.5 and 1.6. I would have to modify for 1.7 and 8.x

Edited by ps8moduly.cz (see edit history)
Link to comment
Share on other sites

Can this module create filters without adding attributes?
What I need is for the product to be simple, but I can add personalised filters.

 

On 7/1/2023 at 7:25 PM, ps8moduly.cz said:

Hi.

Yes, I have already programmed such a solution or module for my customer. It included the option to choose in the product settings whether the attributes should be calculated and matched as a separate product.

Compatible with Prestashop 1.5 and 1.6. I would have to modify for 1.7 and 8.x

 

Link to comment
Share on other sites

What filters?
The module according to settings will update the count for all combinations according to the main product.
It works in the background, whenever the Prestashop function is called to change the number in stock available.

This means that if someone buys a combination of, for example, red, the others, for example, green and blue, will have the same number. In this case, the total sum of the attributes will be the same as the number in the combination.

In short, it's the same as you need.

Combinations: 9 +9 +9 = 9 !!!

Product: 9 = Combinations: 9 + 9 + 9 !!!

obrazek.thumb.png.7a936b1776f34360f174b197f9fa2d04.png

 

obrazek.thumb.png.54d95640972a91c296c5aec3e70de6c4.png

Otherwise, it will be necessary to create separate products from the combinations.

Edited by ps8moduly.cz (see edit history)
Link to comment
Share on other sites

My module is intended for those who sell ash products and have them modified with combinations.
Example:
My company makes wooden toys, for example a train with a wagon.
He has 9 unpainted trains with wagons in stock.
Someone orders red wheels and a green machine and a yellow wagon.
So 1 is subtracted from the warehouse for all combinations, because one "semi-finished" machine with a wagon leaves the warehouse.

Link to comment
Share on other sites

Hi.

I'm sorry, but I have multiple projects at the moment and it's not worth it for me to spend several hours modifying a module for higher versions of Prestashop and one sale.

I'll get to it in 14 days at the earliest.

Unfortunately, I don't even know about any such module. Hopefully someone else can advise. There are a lot of developers and agencies here.

Link to comment
Share on other sites

Ok, for now, it seems i dont have other option, so i will wait for your edit. 
Can you provide the 1.6 version, or a demo? i can try to install 1.6 just to test it a bit, to see if with the API can send the stock info to the right place.  

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...