https://github.com/incapption-public/shopify2googleshopping
https://github.com/incapption-public/shopify2googleshopping
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/incapption-public/shopify2googleshopping
- Owner: incapption-public
- Created: 2022-10-28T12:16:43.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-28T11:08:49.000Z (over 2 years ago)
- Last Synced: 2025-02-18T14:51:28.734Z (4 months ago)
- Language: PHP
- Size: 17.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```