Why can't new products be collected by their metafield value after ERP integration?

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

Hope someone has a solution to this because Shopify API is really confusing for such simple tasks.

Extending this question to give more context:

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 we did works great, 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.

Why is this happening?