create shopify product using php api

Create Shopify product using php api

if you want to create shopify product using api then you need to create first your app in shopify admin. Shopify is an e-commerce platform that lets you create an online store for your products. This activity lets you create a new shopify product in your Shopify account.


Create Acess token and password

Select the appropriate access token for Shopify from the drop-down list. If you haven’t created an access token yet, select ‘Add New’ to create one.

Field data

Shop Name (Mandatory): Provide the name of shop.

Title (Mandatory): Enter the title of your product.

HTML Body (Optional): Enter the description of the product in HTML format.

Vendor Name(Optional): Enter the name of the vendor of the product.

Product Type (Optional): Enter the category under which the product falls. This product type can be used while searching for the products.

Tags (Optional): Enter one or more comma separated tags for the product. The character limit for each tag is 225.

Published (Mandatory): Specify if you wish to publish the product on your Shopify account. By default, the value for this field is set to ‘True’.

Product Variants: Product variant lets you create multiple variants of a single product. E.g., if a t-shirt is available in red, green, and blue color, then ‘T-shirt’ will be the main product and ‘Red’, ‘Green’, and ‘Blue’ will be its product variants.

– Title (Mandatory): Provide a suitable title for the product variant.

– Price (Optional): Enter the price of the product variant.

– Grams (Optional): Enter the weight of the product variant in grams.

You can add multiple product variants by clicking on the ‘+ADD’ link.

Image URL (Optional): Enter the URL of the image that you wish to add to the product. You can add multiple images to the product by clicking on the ‘+ADD’ link.

you need followings things:

1.api key
3.Store name

//Modify these

$url = ‘https://apikey:password@storename/admin/products.xml’;

$template = “<p>Brand:Webtechsource</p><p>Model #:123</p><p>Metal Type:925 SILVER</p><p>Style:beauty</p><p>Details:everything</p>”;

// XML part of product if you need multiple product then do it in loop
$xmlsrc = “<?xml version=’1.0′ encoding=’UTF-8′?>
<title>TESTING PRODUCT</title>
<images type=’array’>



<variants type=’array’>


//Curl Start here

$session = curl_init();
curl_setopt($session, CURLOPT_URL, $url);
curl_setopt($session, CURLOPT_POST, 1);
curl_setopt($session, CURLOPT_POSTFIELDS, $xmlsrc);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_HTTPHEADER, array(‘Accept: application/xml’, ‘Content-Type: application/xml’));
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

if(ereg(“^(https)”,$url)) curl_setopt($session,CURLOPT_SSL_VERIFYPEER,false);
$result = curl_exec($session);
echo $result;

I, Dayanand Saini,the founder and chief editor of,have been working as a software engineer from last 4+ years. It's my hobby to learn new things and implement on live environment.

Leave a Reply

Your email address will not be published. Required fields are marked *

− 1 = 1

%d bloggers like this: