From 43bd7046ae89aaec53408ccc5f8d0f2cc54d7891 Mon Sep 17 00:00:00 2001 From: Vinicius Teixeira Date: Thu, 5 Apr 2018 15:07:24 -0300 Subject: [PATCH 1/2] new method customWithNamespace to allow custom fields with google namespace --- src/LukeSnowden/GoogleShoppingFeed/Item.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/LukeSnowden/GoogleShoppingFeed/Item.php b/src/LukeSnowden/GoogleShoppingFeed/Item.php index 89e6db6..3925b10 100644 --- a/src/LukeSnowden/GoogleShoppingFeed/Item.php +++ b/src/LukeSnowden/GoogleShoppingFeed/Item.php @@ -379,6 +379,18 @@ public function custom($name, $value) $this->nodes[$name] = $node->value($value); } + /** + * Adds a custom attribute to the shopping feed with namespace. + * + * @param string $name + * @param string $value + */ + public function customWithNamespace($name, $value) + { + $node = new Node($name); + $this->nodes[$name] = $node->value($value)->_namespace($this->namespace); + } + /** * Returns item nodes * @return array From 73ac7e9ab6267707a89f7d0f32d3f1a4738e488a Mon Sep 17 00:00:00 2001 From: Vinicius Teixeira Date: Thu, 5 Apr 2018 15:11:08 -0300 Subject: [PATCH 2/2] allow multiple additional images and one (compatibility) --- src/LukeSnowden/GoogleShoppingFeed/Item.php | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/LukeSnowden/GoogleShoppingFeed/Item.php b/src/LukeSnowden/GoogleShoppingFeed/Item.php index 3925b10..be725ad 100644 --- a/src/LukeSnowden/GoogleShoppingFeed/Item.php +++ b/src/LukeSnowden/GoogleShoppingFeed/Item.php @@ -515,12 +515,23 @@ public function pattern($pattern) } /** - * @param $imageLink - */ - public function additional_image_link($imageLink) - { - $node = new Node('additional_image_link'); - $imageLink = $this->safeCharEncodeURL(urldecode($imageLink)); - $this->nodes['additional_image_link'] = $node->value($imageLink)->_namespace($this->namespace)->addCdata(); + * Add one additional image (string) or multiple images (array). + * + * @param $imagesLink + */ + public function additional_image_link($imagesLink) + { + $this->nodes['additional_image_link'] = []; + if (is_array($imagesLink)) { + foreach ($imagesLink as $imageLink) { + $node = new Node('additional_image_link'); + $imageLink = $this->safeCharEncodeURL(urldecode($imageLink)); + array_push($this->nodes['additional_image_link'], $node->value($imageLink)->_namespace($this->namespace)->addCdata()); + } + } else { + $node = new Node('additional_image_link'); + $imageLink = $this->safeCharEncodeURL(urldecode($imagesLink)); + array_push($this->nodes['additional_image_link'], $node->value($imagesLink)->_namespace($this->namespace)->addCdata()); + } } }