I need to write the output from a search request to Amazon Product Api to a CSV (I want to import that into Woocommerce)
Here's what the output looks like (in this exemple, the results returns 2 products)
Array
(
[0] => stdClass Object
(
[ASIN] => B01DA1WRO2
[DetailPageURL] => https://www.amazon.fr/dp/B01DA1WRO2?tag=xxx-21&linkCode=osi&th=1&psc=1
[ItemInfo] => stdClass Object
(
[Title] => stdClass Object
(
[DisplayValue] => Table d'inversion pliable Yatek ECO avec inversion totale, Supporte jusqu'à 150 kg de poids
[Label] => Title
[Locale] => fr_FR
)
)
[Offers] => stdClass Object
(
[Listings] => Array
(
[0] => stdClass Object
(
[Id] => fPdGxBfkTPXhuerR8oHG3BgPbaCR3xtxg4%2B6rXcsMyN1etFVqC6VniXAVFRaFnPWbpz69CGr1EHO5sBLLPMfsbxosLW7C5EpOGTwaulFgrEFH9xeRP8DWgGcX55SwHHwpvL3x8wudeatAN09NhBXFlUAH64HOq%2BIWqPuNq1D1r7JRy%2BMP0lNrQ%3D%3D
[Price] => stdClass Object
(
[Amount] => 159
[Currency] => EUR
[DisplayAmount] => 159,00 €
)
[ViolatesMAP] =>
)
)
)
)
[1] => stdClass Object
(
[ASIN] => B00IR7Z5E4
[DetailPageURL] => https://www.amazon.fr/dp/B00IR7Z5E4?tag=xxx-21&linkCode=osi&th=1&psc=1
[ItemInfo] => stdClass Object
(
[Title] => stdClass Object
(
[DisplayValue] => Sportplus Table d'inversion Pliable, avec système Perfect-Balance, entraîneur à la gravité, 5 Angles d'inversion, soulage la Colonne vertébrale, Max. 135 kg, SP-INV-010
[Label] => Title
[Locale] => fr_FR
)
)
[Offers] => stdClass Object
(
[Listings] => Array
(
[0] => stdClass Object
(
[Id] => fPdGxBfkTPXhuerR8oHG3F%2BdHN8m1gG9kD8UWyw0Vt1A5I7hS%2B1VMB6AI0pD3wa3klDLwl54feL%2BFQYdTcY33QtAzK%2FvhHi7j%2Fwc7Cm6JPEQnPYzZimYkTc6zqS9GvfN2jUiPb%2FT5AY%3D
[Price] => stdClass Object
(
[Amount] => 169.99
[Currency] => EUR
[DisplayAmount] => 169,99 €
)
[ViolatesMAP] =>
)
)
)
[ParentASIN] => B0747RXCK3
)
)
The result is an array that I call $search and if I want to display the data (for exemple the ASIN of the products on a web page), I just do:
foreach ($search as $item) {
echo '$item->ASIN';
}
But I don't understand how to store all the results in a csv file for later use with woocommerce.
Thanks for your help