Skip to content

Commit

Permalink
Fixing clone it method, when using custom method to create a node
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Nowak committed Oct 31, 2018
1 parent d763a2d commit fc06a79
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/LukeSnowden/GoogleShoppingFeed/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ protected function getGroupIdentifier()
*/
public function cloneIt()
{
$groupIdentifiers = $this->getGroupIdentifier();
$groupIdentifiers = $this->getGroupIdentifier();
/** @var Item $item */
$item = $this->googleShoppingFeed->createItem();
$this->item_group_id( $groupIdentifiers );
Expand All @@ -462,7 +462,14 @@ public function cloneIt()
}
}
} elseif ($node->get('name') !== 'shipping') {
$item->{$node->get('name')}($node->get('value'));
if (method_exists($item->{$node->get('name')})) {
$item->{$node->get('name')}($node->get('value'));
return $item;
}

if (!method_exists($item->{$node->get('name')})) {
$item->custom($node->get('name'), ($node->get('value')));
}
}
}
return $item;
Expand Down

0 comments on commit fc06a79

Please sign in to comment.