PHP code example of lukesnowden / google-shopping-feed
1. Go to this page and download the library: Download lukesnowden/google-shopping-feed library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lukesnowden / google-shopping-feed example snippets
use LukeSnowden\GoogleShoppingFeed\Containers\GoogleShopping;
GoogleShopping::title('Test Feed');
GoogleShopping::link('http://example.com/');
GoogleShopping::description('Our Google Shopping Feed');
foreach( $products as $product ) {
$item = GoogleShopping::createItem();
$item->id($id);
$item->title($title);
$item->price($price);
$item->mpn($SKU);
$item->sale_price($salePrice);
$item->link($link);
$item->image_link($imageLink);
...
...
/** create a variant */
$variant = $item->variant();
$variant->size($variant::LARGE);
$variant->color('Red');
/**
* One thing to note, if creating variants, delete the initial object after you've done,
* Google no longer needs it!
*
* $item->delete();
*
*/
}
// boolean value indicates output to browser
GoogleShopping::asRss(true);
$lang = 'gb';
$googleCategories = GoogleShopping::categories($lang);