Closed bizou78 closed 6 years ago
I think I had that error before... but I can't remember how to fix it :-/
Have you tried with a real file (saved on disk) instead of a temp file?
The basic method you're using looks reasonable. My code looks similar:
$clientPack = $mwsClientPool->getFeedAndReportClientPack();
$fileHandle = @fopen($fullFilePath, 'r');
/** @var \MarketplaceWebService_Model_SubmitFeedResponse $mwsResponse */
$mwsResponse = $clientPack->callSubmitFeed($feedType, $fileHandle);
Thank you for your fast response, i'm gonna try your solution as soon as possible and i come back for tell you if it's working.
Thank you very much.
Hi,
I just test your solution and i have the same issue with a real file save on Disk.
you can show my code below:
`$fullPAth = '/var/www/testAmazon/document/report.txt'; var_dump($fullPAth);
$feedHandle = @fopen($fullPAth, 'r');
var_dump($feedHandle);
fwrite($feedHandle, $feed);
$productClientPackUsa->callSubmitFeed('_POST_PRODUCT_DATA_', $feedHandle);
rewind($feedHandle);
@fclose($feedHandle);`
and the var_dump($feedhandle): resource(573, stream)
I don't know what is going wrong here.
Thank you for your help.
I try to follow the code and i think i find something in /var/www/testAmazon/vendor/caponica/amazon-mws-complete/src/AmazonPhpClientLibrary/MarketplaceWebService/Client.php
var_dump($headers);
array_push($headers, "Content-Type: " . $request->getContentType()->toString());
var_dump($headers);
The firsts var_dump() give me a response
/var/www/testAmazon/vendor/caponica/amazon-mws-complete/src/AmazonPhpClientLibrary/MarketplaceWebService/Client.php:1454: array (size=0) empty
But the second return nothing.
Do you think the problem is here ?
Finaly i find the problem, it's from ContentType.php
public function isSetParameters() { return count ($this->fields['Parameters']['FieldValue']) > 0; }
the function call the function count but $this->fields['Parameters']['fieldValue'] is not an array
So i change the function by
public function isSetParameters() { if (is_array($this->fields['Parameters']['FieldValue'])){ return count ($this->fields['Parameters']['FieldValue']) > 0; }else{ return false; } }
and it's work for me.
Do you think it's good ?
I'll try to take a look at this later today and get back to you
OK, so this is caused by your PHP version handling count()
differently to PHP<7.2.0.
Changing the Amazon library is not the best idea, since it will be over-written when the library pack is next updated. (This is obviously frustrating, since some of the code in there is... interesting.)
If you're using PHP 7.2.x I guess you're likely to run into several compatibility issues until Amazon updates the codebase.
Based on the documentation, I'm guessing that you are getting a warning (rather than a fatal error) - is that correct? If so then you may be better using a custom error handler to deal with it rather than changing the Amazon library.
See discussions here and here for more insight, as well as the PHP docs here.
Sorry for my absence and thank you for your answer.
At the moment, i just change my php version for the 7.1 and it's work very well.
I will wait for use the 7.2 :)
Thank you for you help.
Hello Caponica,
First, thank you for your great work on this Bundle, it help me a lot.
At the moment i have no problem on the first part of my work (Get better price of products ), but now i start to try push a product on Amazon with callSubmitFeed() and i have this error "Parameter must be an array or an object that implements Countable".
You can show my code below: `$mwsClientPoolUsa = new MwsClientPool(); $mwsClientPoolUsa->setConfig([ 'amazon_site' => MwsClientPoolConfig::SITE_FRANCE, 'access_key' => 'my_access_key', 'secret_key' => 'my_secret_key', 'application_name' => 'testAmazon', 'application_version' => '1.01', 'seller_id' => 'my_seller_id', ]);
<?xml version="1.0" encoding="iso-8859-1"?>
EOD;
Can you help me a little bit ? Thank you.