An open API service indexing awesome lists of open source software.

https://github.com/incapption-public/shopify2googleshopping


https://github.com/incapption-public/shopify2googleshopping

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# Shopify2GoogleShopping
This is a package to quickly create a XML file for Google Shopping from Shopify products.

### Installation
```bash
composer require incapption/shopify2googleshopping
```

### How to use it

On the PHP side it looks something like this

```php
setShopifyCredentials(
$_ENV['SHOPIFY_PRIVATE_API_KEY'],
$_ENV['SHOPIFY_PRIVATE_API_PASSWORD'],
$_ENV['SHOPIFY_PRIVATE_API_ACCESS_TOKEN'],
"mydemoshop.myshopify.com"
);

// optional: $handler->setTemplate('mypath/custom_template.liquid');

$handler->setProjectTitle('My Custom Shopify Shop');
$handler->setProjectDescription('This is a short description of my shop');
$handler->setProjectLink('https://myshop.shopify.com');

file_put_contents('mypath/product_feed.xml', $handler->generate());
}
}
```

The template looks like this. You can either use the existing template or create your own. It has to be a liquid file.

```liquid


{{ project.title }}
{{ project.description }}
{{ project.link }}

{% for item in items %}

{{ item.title }}
new
{{ item.body_html | strip_html | strip_newlines }}
{{ item.id }}
{{ item.metafield.custom.google_product_category }}
{{ item.image.src }}
{{ project.link }}/products/{{ item.handle }}
{{ item.variants[0].price | decimals: 2, "en-US" | append: " EUR" }}
in stock
{{ item.metafield.custom.gtin }}
{{ item.metafield.custom.brand }}
{{ item.metafield.custom.product_type }}
no

Germany
Download
{{ '0.00' | decimals: 2, "en-US" | append: " EUR" }}


{% endfor %}

```

### Testing
You can test this package. For this you need your Shopify credentials. Make a copy named .env of the .env-example and enter your data.
```bash
./vendor/bin/phpunit tests
```