Shopify

Step-by-Step Guide to Add Products in Shopify Using Laravel

Hello Shopify Friends,

So you have started your Shopify online store and now it’s the time to add products to your Shopify Store. Adding products to the Shopify store is one of the most important steps in building success. You need to display your products in the best version so that the customers can know and love what you have for them in your store.

You can add a product in Shopify using the Admin panel. But here we will learn about adding Products to Shopify using Laravel.

Let’s learn How to Add Product in Shopify using Laravel

Steps to Add Product in Shopify using Laravel:

Step 1: Integrate osiset/laravel-shopify addon with your Shopify app.

Note: You can get customer data either in the controller or in the view file.

Step 2: If you are fetching product data in the controller then add the following class in your controller file after namespace:

use Illuminate\Support\Facades\Auth;

Step 3: Use the following code to add the product.

<?php

    $products_array = array(
        "product" => array( 
            "title"        => 'title of product',
            "body_html"    => 'description',
            "vendor"       => "vendor of product",
            "published"    => true ,
            "variants"     => array(
                array(
                    "sku"     => 'sku of product',
                    "price"   => 'product price',
                    "taxable" => false,
                    "inventory_quantity"=> 'available quantity',
                )
            )
        )
    );
    $shop=Auth::user();

    $products=$shop->api()->rest('POST','/admin/api/2021-07/products.json',$products_array);
?>

Note: The above code snippet consists of common fields for products. You can change it as per your requirement.

Conclusion:

That’s it! This way you can Add Product in Shopify using Laravel. After the products have been added, you need to integrate different payment methods on your Shopify Store.

If somehow you encountered errors, drop a comment below and we will solve it as soon as possible. Share the article with your Shopify developer friends and stay updated for more solutions.

Happy Coding!

Click to rate this post!
[Total: 16 Average: 4.4]
Bharat Desai

Bharat Desai is a Co-Founder at MageComp. He is an Adobe Magento Certified Frontend Developer ? with having 8+ Years of experience and has developed 150+ Magento 2 Products with MageComp. He has an unquenchable thirst to learn new things. On off days you can find him playing the game of Chess ♟️ or Cricket ?.

View Comments

    • You can try this

      $shop = Auth::user();
      $domain = $shop->getDomain()->toNative();
      $shopApi = $shop->api()->rest('DELETE', '/admin/products/{YOUR_PRODUCT_ID}.json')['body'];

      Log::info("Shop {$domain}'s object:" . json_encode($shop));
      Log::info("Shop {$domain}'s API objct:" . json_encode($shopApi));

  • Hi Bharat,
    thank you for your article.
    We are trying to add multiple products by using same library, but it creates duplicates of some of the products.
    Any idea why this might be happening or how to solve it?

    • I have checked the code snippet by my side it is working fine.
      Just check that you are not adding multiple products in the same array which is not allowed.
      You can add one product at a time.

Recent Posts

How to Add Tooltip in Checkout Shipping Field in Magento 2?

Hello Magento Friends, In today’s blog, I will explain How to Add Tooltip in Checkout…

2 days ago

How to Integrate and Use MongoDB with Laravel?

MongoDB is a popular NoSQL database that offers flexibility and scalability when handling modern web…

3 days ago

NodeJS | Callback Function

In NodeJS, callbacks empower developers to execute asynchronous operations like reading files, handling requests, and…

4 days ago

How to Show SKU in Order Summary in Magento 2?

Hello Magento Friends, In today’s blog, we will learn How to Show SKU in Order…

6 days ago

Best Colors to Use for CTA Buttons

The "Buy Now" and "Add to Cart" buttons serve as the primary call-to-action (CTA) elements…

1 week ago

Magento 2: How to Save Custom Field Value to quote_address for Multi-Shipping Orders

Hello Magento Friends, In Magento 2, the checkout process allows customers to choose multiple shipping…

1 week ago