* Added additional methods such as size_system, five custom custom labels (for AdWord campaigns). */ //Without composor (standard installation) /** require('src/NinthYard/GoogleShoppingFeed/Feed.php'); require('src/NinthYard/GoogleShoppingFeed/Item.php'); require('src/NinthYard/GoogleShoppingFeed/Node.php'); require('src/NinthYard/GoogleShoppingFeed/Containers/GoogleShopping.php'); **/ //Using composer require 'vendor/autoload.php'; use NinthYard\GoogleShoppingFeed\Containers\GoogleShopping; GoogleShopping::title('Test Feed'); GoogleShopping::link('http://www.example.com/'); GoogleShopping::description('Test Google Shopping Feed'); $item = GoogleShopping::createItem(); $item->title('An Example Product Title'); $item->price('29.99'); //Price one wishes to sell a product for (unless sale_price option is added, then it's the original price) $item->mpn('ACME00001'); $item->brand('ACME'); $item->sale_price('19.99'); //The actual price one wishes to sell a product for (optional) $item->link('http://www.example.com/example-product.html'); $item->image_link('http://www.example.com/example-image.jpg'); /** Create a variant */ $variant = $item->variant(); $variant->id('SKU0001'); //A SKU code for example, or any unique identifier (eg. could be the id from a database table) $variant->size('L'); $variant->color('Green');
/** * [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; }