How to Get Shopify Product Data using Laravel

How to Get Shopify Product Data using Laravel

Hello Shopify Friends,

In today’s blog, I am going to illustrate How to Get Shopify Product Data using Laravel.

Products are the commodities and services you offer to your customers. While starting an E-commerce online store, you need to add products to your store so that the customers can find out about your offerings. You can perform various actions with products such as create a new product, delete an existing product, update any product, retrieve all products, retrieve any specific product or get the count of total products.

Being a Shopify owner, you need product data for various reasons. Here I have explained retrieving all Product Data, Product Data with specific fields, and retrieving Product Data by ID. 

Steps to Get Shopify Product Data using Laravel:

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

Note: You can get product 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 in the PHP file:

Get all Product Data:

$shop=Auth::user();
$products=$shop->api()->rest('GET','/admin/api/2021-07/products.json');
print_r($products);

Get Specific Product Fields:

$shop=Auth::user();
$products=$shop->api()->rest('GET','/admin/api/2021-07/products.json',["fields"=>"id,title"]);
print_r($products);

Get Product Data by ID:

$shop=Auth::user();
$products=$shop->api()->rest('GET','/admin/api/2021-07/products/{product-id}.json');
print_r($products);

Conclusion:

Hence, this way you can Get Shopify Product Data using Laravel. In the same way, you can also Retrieve Customer Data in Shopify. If you face any challenges while executing the steps, unhesitatingly let me know via the comment section. I will be pleased to provide you with a solution for it.

Make sure you do not forget to share the solution with your other Shopify friends. Stay tuned so that you do not miss out on any significant tutorial.

Happy Coding!

Previous Article

How to set NOINDEX NOFOLLOW for Specific Page in Magento 2

Next Article

How to Integrate Shopify App with Laravel

Write a Comment
  1. let me know how we can get all orders listed and counted from our Shopify store.
    This will help to use our PHP dashboard.

    1. First, you have to use the read_orders access scope then you can get orders data

      For get Order List –
      $shop=Auth::user();
      $orderList=$shop->api()->rest(‘GET’,’/admin/api/2021-07/orders.json?status=any’);

      For Order Count –
      $shop=Auth::user();
      $orderCount=$shop->api()->rest(‘GET’,’/admin/api/2021-10/orders/count.json?status=any’);

Leave a Comment

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

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨