skip to Main Content

I have a partner who owns a warehouse with thousands of products. We want to connect our Magento 2.4.5 store to this partner so that we can sell their products using our Magento 2 store. The partner provided us with API token and url. We need to update the product inventory e.g. every 2 days

We have so far tried the following but encountering challenges.
1- Created system/integration in Magento 2 admin. Used an email and password. Assigned all resources but using custom selection. Copied and saved bearer token.
2- Using postman GET- as per attached I entered the url provided by partner to fetch products from partner warehouse. I selected bearer token option and entered the bearer token supplied by partner. I am able to extract all their products in their thousandsenter image description here
3- Method 1 using postman POST – as per attached I entered our M2 api url using rest/V1/products. I entered bearer token generated in step 1. I then get “Internal error. Details are available in Magento log file. Report ID: webapi-66914793a534d”. when I check system.log I see main.CRITICAL: LogicException: Property "0" does not have accessor
method "get0" in class "MagentoCatalogApiDataProductInterface

4- Method 2 using postman POST – as per attached I entered our M2 rest/V1/integration/admin/token to get admin token. I then entered our M2 api url using rest/V1/products. I used the admin bearer token. I then ger error
"message": "The consumer isn’t authorized to access %resources.",
"parameters": {
"resources": "Magento_Catalog::products"

5- Method using guzzle – installed guzzle using compose composer require guzzlehttp/guzzle. Followed instruction on https://devhooks.in/blog/how-to-perform-3rd-party-api-operations-in-your-magento-using-guzzlehttp. I got lost as I am nost sure where to put this guzzle file and how to invoke it. The same applies to https://developer.adobe.com/commerce/php/tutorials/backend/create-api-integration/ as I have no idea where to place the file and how to invoke it.
6- I followed Mageplaza guide https://www.mageplaza.com/devdocs/magento-2-create-api/ to create a custom api module but got lost how to use it to fetch the products and place them in their appropriate M2 categories
7- I explored curl scripts from w3schools but my confusion is same as with using guzzle
Has anyone got experience with this that they can guide me to a working solution?

2

Answers


  1. Chosen as BEST ANSWER

    Here is the json file. The actual file has thousands of products but I have just used one product to test the json file payload. Error is "message": "Internal Error. Details are available in Magento log file. Report ID: webapi-6697ea5ae39b1"

    {
        "product": [
            {
                "Product_Number": "APCRBC105",
                "Manufacturing_Part_Number": "APCRBC105",
                "Short_Advertising_Description": "Apc Replacement Battery Cartridge 
                 #105",
                "Product_Description": "APC REPLACEMENT BATTERY CARTRIDGE 105",
                "BarCode": "731304248729",
                "Product_Type": "Battery ",
                "Manufacturer": "APC",
                "Category": "Accessories",
                "Available_Stock": 0,
                "Price_ex_Vat": 7293.0,
                "Date_Added": "2015-08-21T12:51:28.19",
                "Image_URL": 
                "https://s3.amazonaws.com/tarsus.co.za/APCRBC105_default.jpg",
                "Export_Date": "2024-07-09T14:53:15.053",
                "Serialized": "No",
                "ETA_Date": null,
                "Non_Discount_Price_ex_Vat": 7293.0,
                "Discount_Quantity": 0,
                "Product_Discounted": "No",
                "Each_Width": 33.00,
                "Each_Height": 27.00,
                "Each_Length": 74.00,
                "Each_Weight": 26.14
            }
       ]
    }
    

  2. Can you provide 1 whole product data that you are fetching from you partner and to update inventory after every 2days you need to write a cron job for that in which we get product data and update that product in magento.

    In that cron job you can use curl to get the products through api get the result in json and then use that json data to update product inventory.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search