$variant->color('Green'); $variant = $item->variant(); $variant->id('SKU0005'); //A SKU code for example, or any unique identifier (eg. could be the id from a database table) $variant->size('M'); $variant->color('Blue'); $variant = $item->variant(); $variant->id('SKU0006'); //A SKU code for example, or any unique identifier (eg. could be the id from a database table) $variant->size('M'); $variant->color('Red'); $variant = $item->variant(); $variant->id('SKU0007'); //A SKU code for example, or any unique identifier (eg. could be the id from a database table) $variant->size('S'); $variant->color('Green'); $variant = $item->variant(); $variant->id('SKU0008'); //A SKU code for example, or any unique identifier (eg. could be the id from a database table) $variant->size('S'); $variant->color('Blue'); $variant = $item->variant(); $variant->id('SKU0009'); //A SKU code for example, or any unique identifier (eg. could be the id from a database table) $variant->size('S'); $variant->color('Red'); // Delete initial $item as we're using variants and it will not be needed $item->delete(); // boolean value true outputs to browser as XML GoogleShopping::asRss(true);
/** * [clone description] * @return [type] [description] */ public function cloneIt() { $item = GoogleShopping::createItem(); $this->item_group_id($this->nodes['mpn']->get('value') . '_group'); foreach ($this->nodes as $node) { if (is_array($node)) { $name = $node[0]->get('name'); foreach ($node as $_node) { if ($name == 'shipping') { $xml = simplexml_load_string('<foo>' . trim(str_replace('g:', '', $_node->get('value'))) . '</foo>'); $item->{$_node->get('name')}($xml->country, $xml->service, $xml->price); } else { $item->{$name}($_node->get('value')); } } $item->{$node->get('name')}($node->get('value')); } } return $item; }