Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webservice add order do not call 'actionUpdateQuantity' #13395

Closed
pppplus opened this issue Apr 13, 2019 · 24 comments
Closed

webservice add order do not call 'actionUpdateQuantity' #13395

pppplus opened this issue Apr 13, 2019 · 24 comments
Labels
Duplicate Resolution: issue closed because already reported Old Products Page Concerns the old product page Order Component: Which BO section is concerned WS Category: Web Service

Comments

@pppplus
Copy link

pppplus commented Apr 13, 2019

Describe the bug
When I do order with webservice, quantities of products are not updated

Additionnal information
PrestaShop version: 1.7.5.1
PHP version: 7.2

I think it was ok on 1.7.5.0, because, I've done a lot of tests.
I just see my stock do not decrease with webservice orders.

@khouloudbelguith
Copy link
Contributor

Hi @pppplus,

Could you please provide me your script to test with it.

Thanks!

@khouloudbelguith khouloudbelguith added NMI Status: issue needs more information Order Component: Which BO section is concerned Old Products Page Concerns the old product page Webservice Label: Which BO under menu is concerned labels Apr 15, 2019
@pppplus
Copy link
Author

pppplus commented Apr 15, 2019

Hi, yes it's possible.
But difficult to use for you I think, because the script is only for me.

Is it possible to send it privatly ?

@khouloudbelguith
Copy link
Contributor

khouloudbelguith commented Apr 16, 2019

Hi @pppplus,

My address mail: khouloud-belguith.ext@prestashop.com

Thanks!

@pppplus
Copy link
Author

pppplus commented Apr 17, 2019

Ok, I prepare the files, and send them in a few minutes.
Thanks

@khouloudbelguith
Copy link
Contributor

Hi @pppplus,

Thank you, we received your e-mail.
We will try to reproduce it and we will come back to you if we need more information.

@khouloudbelguith khouloudbelguith added WS Category: Web Service and removed Webservice Label: Which BO under menu is concerned labels Apr 18, 2019
@khouloudbelguith
Copy link
Contributor

Hi @pppplus,

When I tried with your file, I have these errors.

</ul><br/>TEST idPayment <br/>PHP Notice:  Undefined variable: public_key in /projet/php5/presta_test/1751/testMWSamazon.php on line 242
PHP Stack trace:
PHP   1. {main}() /projet/php5/presta_test/1751/testMWSamazon.php:0
PHP Notice:  Undefined variable: private_key in /projet/php5/presta_test/1751/testMWSamazon.php on line 242
PHP Stack trace:
PHP   1. {main}() /projet/php5/presta_test/1751/testMWSamazon.php:0
https://mws.amazonservices.fr/Orders/2013-09-01?AWSAccessKeyId=&Action=ListOrderItems&AmazonOrderId=408-4137542-8205953&SellerId=A3L7R8BEGV2OZE&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2019-04-18T15%3A23%3A20Z&Version=2013-09-01&Signature=U6GQLm5835W6DDpGKL%2BP11hGqUeWlKCk2YKnmVh351c%3DPHP Fatal error:  Uncaught Exception: String could not be parsed as XML in /projet/php5/presta_test/1751/testMWSamazon.php:246
Stack trace:
#0 /projet/php5/presta_test/1751/testMWSamazon.php(246): SimpleXMLElement->__construct('')
#1 {main}
  thrown in /projet/php5/presta_test/1751/testMWSamazon.php on line 246

Thanks to check & feedback.

@khouloudbelguith
Copy link
Contributor

khouloudbelguith commented Apr 22, 2019

Hi @pppplus,

Now, I have this error

</ul><br/>TEST idPayment <br/>PHP Warning:  Invalid argument supplied for foreach() in /projet/php5/presta_test/1751/testMWSamazon.php on line 336
PHP Stack trace:
PHP   1. {main}() /projet/php5/presta_test/1751/testMWSamazon.php:0
Panier VIDE, on sort de la boucle.<br/><hr/><br/><h2>Récapitulatif</h2><h3>ID produit Prestashop</h3><h3>Sku INVALIDES</h3>

I think because you use in your script you use Amazon, in my case no.
Thanks to check & feedback

@pppplus
Copy link
Author

pppplus commented Apr 27, 2019

Hi @khouloudbelguith
Do you receive my last version, and do you reproduce the problem ?
I urgently need a solution now... my stock are not updated, and it's very hard to work !!

@khouloudbelguith
Copy link
Contributor

Hi @pppplus,

Yes, I just received your last version, but as I said, I have a new errors with your script.

</ul><br/>TEST idPayment <br/>PHP Warning:  Invalid argument supplied for foreach() in /projet/php5/presta_test/1751/testMWSamazon.php on line 336
PHP Stack trace:
PHP   1. {main}() /projet/php5/presta_test/1751/testMWSamazon.php:0
Panier VIDE, on sort de la boucle.<br/><hr/><br/><h2>Récapitulatif</h2><h3>ID produit Prestashop</h3><h3>Sku INVALIDES</h3>

Thanks to check & feedback.

@pppplus
Copy link
Author

pppplus commented Apr 29, 2019

Hi
That's not possible.
I check my script on a new website to be sure.
Do you create Products, as I describe in my email ?

@khouloudbelguith
Copy link
Contributor

@pppplus, Yes, I created the two products with the references described & after runing your file, I have
errors
image

lue in \AmazonSeller\testMWSamazon.php on li
ne 334

Warning: Creating default object from empty value in \AmazonSeller\testMWSamazon.php on line 334
PHP Warning:  Invalid argument supplied for foreach() in \AmazonSeller\testMWSamazon.php on line 336

Warning: Invalid argument supplied for foreach() in \AmazonSeller\testMWSamazon.php on line 336
Panier VIDE, on sort de la boucle.<br/><hr/><br/><ul>
            <li>BuyerEmail = xxx7z47dnmxrql7@marketplace.amazon.fr</li>
            <li>AmazonOrderId = 405-7456972-0653950</li>
            <li>SalesChannel = Amazon.fr</li>
            <li>BuyerName = GUERTHON</li>
            <li>OrderTotal = 10.99EUR</li>
            <li>ShippingAddress = <ul>
                <li>Phone = 0609233570</li>
                <li>City = Mont D Or</li>
                <li>StateOrRegion = </li>
                <li>CountryCode = FR</li>
                <li>PostalCode = 36270</li>
                <li>Name = BERTHON VALERIE</li>
                <li>AddressLine1 =20 rue Geroget</li>
                <li>AddressLine2 =</li>
            </ul></li>
            </ul>Bad auth keyPHP Warning:  Invalid argument supplied for foreach
() in \AmazonSeller\testMWSamazon.php on lin
e 336

Warning: Invalid argument supplied for foreach() in \AmazonSeller\testMWSamazon.php on line 336
Panier VIDE, on sort de la boucle.<br/><hr/><br/><h2>R├®capitulatif</h2><h3>ID p
roduit Prestashop</h3><h3>Sku INVALIDES</h3>

I sent you via email the exact script that I followed
Thanks to check & feedback

@pppplus
Copy link
Author

pppplus commented May 9, 2019

Hi
Do you try the last version I sent to you on 3rd of may ?

@khouloudbelguith
Copy link
Contributor

@pppplus, no sorry I did not receive your email yet.
Thanks to check & feedback.

@pppplus
Copy link
Author

pppplus commented May 10, 2019

Ok, I just sent it again.

@khouloudbelguith
Copy link
Contributor

@pppplus, Thanks a lot for your feedback.
I have this error now
image
Thanks to check & feedback.

@khouloudbelguith
Copy link
Contributor

Hi @pppplus,

Since we had no news from you for more than 30 days, I'll close this ticket. Feel free to open another one if you can give specific details.

Thanks!

@khouloudbelguith khouloudbelguith added No change required Resolution: issue closed because expected as is and removed NMI Status: issue needs more information labels Jun 10, 2019
@pppplus
Copy link
Author

pppplus commented Jun 16, 2019

Ok, after a lot of research... I have something to propose.

1st : actionUpdateQuantity is never called, when an order is done from webservice.
2nd : product quantities (of pack item) are not updated when a pack is ordered from webservice => that's a bug I suppose ??
3rd : the problem seems to be in /clsses/StockAvailable/StockAvailable.php

public function updateWs() { if ($this->depends_on_stock) { return WebserviceRequest::getInstance()->setError(500, $this->trans('You cannot update the available stock when it depends on stock.', array(), 'Admin.Catalog.Notification'), 133); } return $this->update(); }

function update() call function postSave()

And first action of postSave is to exit on id_product_attribute == 0
Why ? I don't know !

So, my suggestion, modify the function updateWs() like this :
`
public function updateWs()
{
if ($this->depends_on_stock) {
return WebserviceRequest::getInstance()->setError(500, $this->trans('You cannot update the available stock when it depends on stock.', array(), 'Admin.Catalog.Notification'), 133);
}

    //add this
    if ($this->id_product_attribute == 0) {
        $this->setQuantity($this->id_product, $this->id_product_attribute, $this->quantity, $this->id_shop);
    }
    //end modificatin

    return $this->update();
}

`

function setQuantity() call the hook actionUpdateQuantity (so, modules with actionUpdateQuantity can now work !!)

BUT, to be usefull :
1- update manually item quantities of the item in the pack (via webservice stock_availables)
2- update manually quantities of the pack (via webservice stock_availables)

@pppplus
Copy link
Author

pppplus commented Jun 16, 2019

I just hope function updateWs() is called only from Webservice !!

@khouloudbelguith
Copy link
Contributor

@pppplus, Would you be willing to make a pull request on GitHub with your code suggestion?
https://github.com/PrestaShop/PrestaShop/tree/develop
Thank you!

@pppplus
Copy link
Author

pppplus commented Jun 17, 2019

Hi

No, because I'm not sure it's the right method to do it.
It's just for me, a solution, to have the hook working.

But I'm not sure, there is no bad things after my changes.
I think someone has to review my method, to implement it.

@pppplus
Copy link
Author

pppplus commented Sep 8, 2019

In PS 1.7.6.1 always the same problems.

@pppplus
Copy link
Author

pppplus commented Sep 18, 2020

Always same problem in 1.7.6.7

@khouloudbelguith
Copy link
Contributor

Hi @pppplus,

Please follow this issue: #13006
Your ticket is a duplicate of #13006
So, I close it.
Thanks!

@khouloudbelguith
Copy link
Contributor

Duplicate of #13006

@khouloudbelguith khouloudbelguith marked this as a duplicate of #13006 Sep 25, 2020
@khouloudbelguith khouloudbelguith added Duplicate Resolution: issue closed because already reported and removed No change required Resolution: issue closed because expected as is labels Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Resolution: issue closed because already reported Old Products Page Concerns the old product page Order Component: Which BO section is concerned WS Category: Web Service
Projects
None yet
Development

No branches or pull requests

2 participants