I have a foreach loop ($product_image) and an array ($newProductData), what I am trying to do is put the foreach content ($mediagalleryURLs) into the $newProductData array, when I print_r $newProductData, the the output shows only the last foreach element as $newProductData['media_gallery'] value, not the full elements, here is the code:
<?php
...
$resimURLNew = (string) $item->xpath('images/image[@main=1]')[0];
foreach($item->images->image as $product_image) {
$mediagalleryURLs = $product_image.';';
$mediagalleryURLs = rtrim($mediagalleryURLs, ';');
}
$newProductData = array(
'sku' => (string) $item->id,
'barcode' => (string) $item->barcode
);
$newProductData['image'] = (string) $resimURLNew;
$newProductData['small_image'] = (string) $resimURLNew;
$newProductData['thumbnail'] = (string) $resimURLNew;
$newProductData['media_gallery'] = $mediagalleryURLs;
...
?>
$mediagalleryURLson each iteration of the foreach loop.