Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed static calls from Item class allowing for non-static usage of… #30

Merged

Conversation

johanlerche
Copy link
Contributor

@johanlerche johanlerche commented Apr 5, 2018

Allowing for non-static usage of Feed, e.g.:

use LukeSnowden\GoogleShoppingFeed\Feed;

$feed = new Feed();
$feed->title('Test Feed');
$feed->link('http://example.com/');
$feed->description('Our Google Shopping Feed');

foreach( $products as $product ) {

$item = $feed->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
$feed->asRss(true);

Everything else will still work as before ;-)

@lukesnowden lukesnowden merged commit 2313d42 into lukesnowden:master Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants