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

Getting null reference from api when updating stock availability #120

Closed
iang0ld opened this issue Feb 9, 2015 · 3 comments
Closed

Getting null reference from api when updating stock availability #120

iang0ld opened this issue Feb 9, 2015 · 3 comments
Assignees
Labels

Comments

@iang0ld
Copy link

iang0ld commented Feb 9, 2015

This has been working previously, but not now.

StockAvailableFactory StockAvailableFactory = new StockAvailableFactory(ApiAddress, ApiAccount, ApiSecretKey);

Dictionary<string, string> dtn = new Dictionary<string, string>();
dtn.Add("id_product", product["ExtID"].ToString());
dtn.Add("id_product_attribute", product["ExtGroupID"].ToString()); // id_attribute_id is actually the combinationid

List<stock_available> stock = StockAvailableFactory.GetByFilter(dtn, null, null);

if (stock != null)
{
stock.First().quantity = stock.First().quantity + (int)Math.Floor(qtychange);
// DATA IS PERFECT UP TO THIS POINT
StockAvailableFactory.Update(stock.First());
}

public void Update(Entities.stock_available StockAvailable)
{
RestRequest request = this.RequestForUpdate("stock_availables", StockAvailable.id, StockAvailable);
// DATA IS PERFECT UP TO THIS POINT

this.Execute<Entities.stock_available>(request); // NOW IT FALLS APART AND API RETURNS ERROR NULL REFERENCE.
}

@EduLeonPavon EduLeonPavon self-assigned this Feb 9, 2015
@EduLeonPavon
Copy link
Member

Hello @iang0ld
Please, enable display php errors (https://github.com/Bukimedia/PrestaSharp/blob/master/Enable%20display%20errors%20in%20Prestashop.txt)
After that, run your code and paste the error.
Best regards.

@iang0ld
Copy link
Author

iang0ld commented Feb 9, 2015

Hi. We have a problem. I don’t have access to the site I use for testing. It is a live site of a customer.

From: Eduardo León Pavón [mailto:notifications@github.com]
Sent: Monday, 9 February 2015 9:50 PM
To: Bukimedia/PrestaSharp
Cc: Ian Gold
Subject: Re: [PrestaSharp] Getting null reference from api when updating stock availability (#120)

Hello @iang0ldhttps://github.com/iang0ld
Please, enable display php errors (https://github.com/Bukimedia/PrestaSharp/blob/master/Enable%20display%20errors%20in%20Prestashop.txt)
After that, run your code and paste the error.
Best regards.


Reply to this email directly or view it on GitHubhttps://github.com//issues/120#issuecomment-73489526.

@guywang
Copy link

guywang commented May 25, 2016

Hi
I have the same issue as @iang0ld experienced (null reference when I tried to update the stock_available), any ideas to fix it?

I used fiddler to compose the PUT request for updating stock_available and the error message is
Fatal error: Class name must be a valid object or a string in C:\inetpub\wwwroot\PrestashopDemo\classes\webservice\WebserviceRequest.php on line 1408

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants