From beb8b858ddbb7a62372fa48a8b66be1ed64ad511 Mon Sep 17 00:00:00 2001 From: Szymon Nowak Date: Tue, 19 Feb 2019 04:52:36 -0500 Subject: [PATCH] Fixing cloneIt method. It was loosing array nodes during cloning. Instead of multiple nodes with the same name, only one (last) was left in the cloned item --- src/LukeSnowden/GoogleShoppingFeed/Item.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/LukeSnowden/GoogleShoppingFeed/Item.php b/src/LukeSnowden/GoogleShoppingFeed/Item.php index 7463661..69c6231 100644 --- a/src/LukeSnowden/GoogleShoppingFeed/Item.php +++ b/src/LukeSnowden/GoogleShoppingFeed/Item.php @@ -452,15 +452,19 @@ public function cloneIt() if (is_array($node)) { // multiple accepted values.. $name = $node[0]->get('name'); + $multipleNodes = array(); foreach ($node as $_node) { if ($name == 'shipping') { // Shipping has another layer so we are going to have to do a little hack $xml = simplexml_load_string('' . trim(str_replace('g:', '', $_node->get('value'))) . ''); $item->{$_node->get('name')}($xml->country, $xml->service, $xml->price); } else { - $item->{$name}($_node->get('value')); + $multipleNodes[$name][] = $_node->get('value'); } } + if (count($multipleNodes)) { + $item->{$name}($multipleNodes[$name]); + } } elseif ($node->get('name') !== 'shipping') { if (method_exists($item, $node->get('name'))) { $item->{$node->get('name')}($node->get('value'));