Integrating ERP With Shopify

We migrated from Magento to Shopify with all the metafield values and we have been trying to integrate an ERP system with Shopify and we had a lot of issue regarding collecting products with metafield values (ERP ID).

Reading a lot of forum discussions we have stumbled upon a solution where:

  1. You can filter a product by it’s metafield value through a collection
  2. We created a collection which contains all the products
  3. Extending the API to be able to filter products with ERP ID
  4. Products which had the ERP ID metafield value from the migration are able to be collected
  5. New products which are being created and put the value of the ERP ID manually or through the API are not able to be collected with this method

Questions:

  1. Is there any other way for the products to be collected by their metafield value?
  2. Why the above method is not working? Migrated products with the ERP ID metafield value can be collected, when trying to collect a new product the response is null.

We found an example for collecting products with their metafield value but it does not work:

https://{{api_key}}:{{api_password}}@{{store_name}}.myshopify.com/admin/api/{{api_version}}/products.json?metafields.namespace=magento&metafields.key=ceid&metafields.value=123

The GraphQL query for collecting a product with a specific ERP ID through a collection is the below:

query ProductERP {
  collection(handle: "erp") {
    products(
      first: 1
      filters: {
        productMetafield: { namespace: "magento", key: "ceid", value: "123" }
      }
    ) {
      edges {
        node {
          id
          handle
          title
          totalInventory
          vendor
          variants(first: 15) {
            edges {
              node {
                id
                sku
              }
            }
          }
        }
      }
    }
  }
}

Collecting products which were imported through the magento migration which already had the ERP ID as a metafield imported can be collected, although when we create a new product through the API or even manually with the same metafield (namespace and key) we are unable to collect it, it returns null.

It seems like you are trying to use the Shopify API to retrieve products by their metafield values, but you are experiencing some issues. Here are a few possible reasons why the above method might not be working as expected:

  1. The metafields for the new products are not being created correctly. It is possible that there is an issue with the code or the API call that is causing the metafields for the new products to not be created correctly.

  2. The metafields for the new products are being created, but they are not being associated with the correct products. This could be due to an issue with the code or the API call that is causing the metafields to be associated with the wrong products.

  3. There is a problem with the GraphQL query that you are using to retrieve the products. It is possible that the query is not correctly filtering the products by their metafield values.

To troubleshoot these issues, you may want to try the following:

  1. Check the code or the API calls that you are using to create the metafields for the new products to make sure that they are being created correctly.

  2. Check the code or the API calls that you are using to associate the metafields with the correct products to ensure that they are being correctly linked.

  3. Review the GraphQL query that you are using to retrieve the products and make sure that it is correctly filtering the products by their metafield values.

It is also a good idea to check the Shopify documentation for more information on using metafields and the Shopify API to retrieve products. The documentation should provide more detailed information on how to correctly use these features.

This answer doesn’t really help the case.

Hello, thanks for taking the time to reply.

I found out that the issue was that the product wasn’t active and the Sales channels and apps didn’t had the Online Store selected.

Fixing the above issues made it work.