Skip to content

Commit

Permalink
Added readme
Browse files Browse the repository at this point in the history
+ small fixed in Feed.php
  • Loading branch information
Deniz Tezcan committed Sep 6, 2019
1 parent d018130 commit 672ac6c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
43 changes: 41 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# laravel-google-shopping
Laravel Google Shopping package
Laravel Google Shopping
==============

[![Latest Stable Version](https://poser.pugx.org/deniztezcan/laravel-google-shopping/v/stable)](https://packagist.org/packages/deniztezcan/laravel-google-shopping)
[![Total Downloads](https://poser.pugx.org/deniztezcan/laravel-google-shopping/downloads)](https://packagist.org/packages/deniztezcan/laravel-google-shopping)
[![Latest Unstable Version](https://poser.pugx.org/deniztezcan/laravel-google-shopping/v/unstable)](https://packagist.org/packages/deniztezcan/laravel-google-shopping)
[![License](https://poser.pugx.org/deniztezcan/laravel-google-shopping/license)](https://packagist.org/packages/deniztezcan/laravel-google-shopping)

## Installation

```
composer require deniztezcan/laravel-google-shopping
```

## Example
```php
use DenizTezcan\LaravelGoogleShopping\LaravelGoogleShopping;

LaravelGoogleShopping::setTitle('Example feed');
LaravelGoogleShopping::setDescription('Example feed of the Example shop');
LaravelGoogleShopping::setLink('https://example.shop');

LaravelGoogleShopping::addItem(
"https://example.shop/p/foo-bar",
"SKU123",
"Foo bar",
"https://example.shop/images/foo-bar.png",
"Foo bar best product",
'new',
99.99,
'Foo brand',
'6387712293758',
[
'country' => 'NL',
'service' => 'PostNL - Gratis',
'price' => 0
]
);

return LaravelGoogleShopping::display();
```
7 changes: 3 additions & 4 deletions src/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function addItem(

public function generate()
{
$this->xml[] = [
$this->xml = [
'rss' => [
'_attributes' => [
'xmlns:g' => 'http://base.google.com/ns/1.0',
Expand All @@ -100,6 +100,7 @@ public function generate()

foreach ($this->products as $product) {
$this->xml['rss']['channel']['item_'.$i] = $product;
$i++;
}

$xml = ArrayToXml::convert($this->xml, '');
Expand All @@ -116,9 +117,7 @@ public function generate()

public function display()
{
header("Content-type: text/xml");
print $this->generate();
exit;
return response($this->generate())->header('Content-Type', 'text/xml');
}

}

0 comments on commit 672ac6c

Please sign in to comment.