Seamlessly Generate CSV Files for a Subset of Products
Our new CSV Exporter feature allows you to effortlessly generate CSV files tailored to the
Magento, Shopify & Custom formats.
This powerful tool enables you to select a specific subset of products from your supplier's
catalog and export the data with ease.
Example of a Shopify store populated using this feature: SwagPath.com
This feature leverages the latest Product Data version 2.0.0 and Media Content version 1.1.0, ensuring you get the most accurate and up-to-date information in your CSV exports.
Supplier | Environment | Category | Format | Link |
---|---|---|---|---|
Ariel Premium Supply | PROD | Drinkware | Magento | Download |
Hit Promotional Products | PROD | Few selected products | Shopify Product | Download |
Hit Promotional Products | PROD | Few selected products | Shopify Inventory | Download |
Ariel Premium Supply | PROD | Few selected products | Shopify MinMaxfy | Download |
The Magento format is a CSV file that contains the following columns:
The Shopify Product format is a CSV file useful for importing & updating your
products on
Shopify store.
It will contain the following columns:
The Shopify Inventory format is a CSV file for updating your inventory on
Shopify store.
The last column is Location, you should change your Location in Shopify to be
named Default to match the CSV file.
It will contain the following columns:
The Shopify MinMaxfy format is a CSV file that contains the following columns:
It is a CSV for the MinMaxfy App used to set the minimum and maximum quantities for a product. The Multiple column is used to set the quantity increment. So we defaulted to 1.
Here is their documentation for the file.
Once you download the CSV from PSRESTful you can start the process to import it into your Shopify store.
Here are the steps to import your CSV(exported from PSRESTful) into Shopify:
Forcing minimum quantity only using metafield and a minimum change on main-product.liquid.
No need to adding rules or anything else.
The CSV will return a column called minimum_quantity, this field can be accessed in Shopify liquid by product.metafields.psrestful.minimum_quantity after you create this metafield in Shopify.
To modify the main-product-liquid file.
{%- assign min_qty = product.metafields.psrestful.minimum_quantity
-%}
This will allow you to use min_qty later in the liquid template.
<input
class="quantity__input"
type="number"
name="quantity"
id="Quantity-{{ section.id }}"
data-cart-quantity="{{ cart_qty }}"
data-min="{{ min_qty }}"
min="{{ min_qty }}"
{% if product.selected_or_first_available_variant.quantity_rule.max != null %}
data-max="{{ product.selected_or_first_available_variant.quantity_rule.max }}"
max="{{ product.selected_or_first_available_variant.quantity_rule.max }}"
{% endif %}
step="{{ product.selected_or_first_available_variant.quantity_rule.increment }}"
value="{{ min_qty }}"
form="{{ product_form_id }}"
>
Save time by using a Python script to add our metafields
When you need to add metafields to your Shopify store, you can use a Python script to automate the process. This is especially useful when you have a large number of products or need to update the metafields frequently.
We've open-sourced a Python script that simplifies adding metafields to your Shopify store via the Shopify API.
Shopify-psrestful has
its own readme file to help developers to use it.
Here is a piece of code to illustrate
@dataclass
class Spec:
name: str
key: str
description: str
field_type: str = 'single_line_text_field'
owner_type: str = 'PRODUCT'
SPECS = (
# product
Spec(name='Supplier Code', key='supplier_code', description='Supplier Code', field_type='single_line_text_field'),
Spec(name='PS Product ID', key='product_id', description='Product ID from PromoStandards',
field_type='single_line_text_field'),
Spec(name='Extra ID', key='extra_id', description='Extra ID from PSRESTful API', field_type='number_integer'),
Spec(name='Effective Date', key='effective_date',
description='The Date this Product initially becomes available from the Supplier in ISO 8601 format',
field_type='date'),
Spec(name='Export', key='export', description='Product status for export', field_type='boolean'),
Spec(name='Primary Material', key='primary_material', description='Primary material of construction',
field_type='single_line_text_field'),
Spec(name='Brand', key='brand', description='Brand of the Product', field_type='single_line_text_field'),
Spec(name='Country of Origin', key='country_of_origin', description='Country of Origin of the Product',
field_type='single_line_text_field'),
Spec(name='Is Caution', key='is_caution',
description='Cautionary status to review for specific warnings about using product data.',
field_type='boolean'),
Spec(name='Caution Comment', key='caution_comment', description='Caution', field_type='boolean'),
Spec(name='Line Name', key='line_name', description='Line Name / Division to which this product belongs',
field_type='single_line_text_field'),
Spec(name='Minimum Quantity', key='minimum_quantity', description='Minimum quantity to order',
field_type='number_integer'),
Spec(name='Lead Time', key='lead_time', description='Lead time in days', field_type='number_integer'),
Spec(name='Is On Demand', key='is_on_demand', description='Product is available on demand', field_type='boolean'),
Spec(name='Is Rush Service', key='is_rush_service', description='Product is available as a rush service',
field_type='boolean'),
Spec(name='Imprint Size', key='imprint_size', description='The imprint Size', field_type='single_line_text_field'),
Spec(name='Price Expires Date', key='price_expires_date', description='The Date this Product price expires',
field_type='datetime'),
Spec(name='Is Hazmat', key='is_hazmat', description='Contains hazardous material. A nil value indicates this it'
'is unknown or the data is not available by the supplier',
field_type='boolean'),
Spec(name='Price Expires Date', key='price_expires_date',
description='The date that the pricing in the ProductPriceGroupArray portion of the response expires',
field_type='datetime'),
Spec(name='Default SetUp Charge', key='default_set_up_charge',
description='The default setup charge for this product. Can be a textual description',
field_type='single_line_text_field'),
Spec(name='Default Run Charge', key='default_run_charge',
description='The default RUN charge for this product. Can be a textual description',
field_type='single_line_text_field'),
Spec(name='UNSPSC Commodity Code', key='unspsc_commodity_code',
description='The United Nations Standard Products and Services CodeĀ® (UNSPSCĀ®) that best describes this '
'product. Note that the enumerated values are the UNSPSC "Commodity" codes. For more information, '
'refer to https://www.unspsc.org',
field_type='number_integer'),
# Variant
Spec(name='Variant GTIN', key='variant_gtin', description='Global Trade Item Number',
field_type='single_line_text_field', owner_type='ProductVariant'),
)
def create_meta_fields_from_specs(shopify_domain, access_token, meta_field_specs=SPECS):
with get_shopify_session(shopify_domain, access_token):
for spec in meta_field_specs:
create_metafield(spec.name, spec.key, spec.description,
field_type=spec.field_type, owner_type=spec.owner_type)
def create_metafield(name: str, key: str, description: str,
namespace: str = 'psrestful',
field_type: str = 'single_line_text_field', owner_type: str = 'PRODUCT'):
query = '''
mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) {
metafieldDefinitionCreate(definition: $definition) {
createdDefinition {
id
name
namespace
key
description
}
userErrors {
field
message
code
}
}
}
'''
variables = {
"definition": {
"name": name,
"namespace": namespace,
"key": key,
"description": description,
"type": field_type,
"ownerType": owner_type
}
}
response = shopify.GraphQL().execute(query, variables)
return response
Avoid checkout issues by updating your inventory using a Python script
We have created another command in the open source code located at Github.
The update-inventory command will help you to keep your inventory update date.
This is a CLI tool to help with the integration of Shopify and PSRESTful, and it is meant to be used as a
standalone tool
but in combination with the CSV Exporter in PSRESTful.
If you already have products in your store and want to update the inventory, you just need to add the metafields supplier_code and product_id to your products. Then, you will be ready to update inventory using this script.
You should use a machine where you can run Python. If using Linux use a cronjob. For most cases, running the script once a day is enough. Remember, you will be hitting your Shopify store, PSRESTful, and the supplier. After midnight is a good time to run the script.
Depending on the number of products in your store this can be an slow process. This is why it is recommended to run it on background. We have also included a retry logic to avoid rate limit errors.
nohup ./src/shopify_psrestful/cli.py -c update-inventory &
Shopify provides two ways to create an app: Custom Apps and Public Apps. If you're building an integration for your own store, use a Custom App.
Once the app is created, retrieve the necessary API credentials:
SHOPIFY_APP_PRIVATE_APP_PASSWORD
).
Your store URL follows this format:
https://{your-store-name}.myshopify.com
Use this value for SHOPIFY_APP_SHOP_URL
.
.env
FileCreate a .env
file in your project directory and add the credentials:
SHOPIFY_APP_API_KEY='your_api_key'
...