Hi Muhammad,
When you manually export products to a CSV file from the Shopify store, the fields that are exported are pre-defined by Shopify. While it’s true that custom metafields without definitions will be included, metafields with definitions will not be included in the manual export.
This is because defined metafields are expected to have a specific structure and validation rules, which might not be preserved in a CSV export. Exporting such data may lead to potential data corruption or loss when re-imported. The best way to handle this scenario is to use the Shopify API, as you have done, which allows for a more granular control over data exports and imports.
As for your second query, yes, you can import metafields back into Shopify. You can use either the REST or GraphQL API, depending on your preference. If you use the REST API, you can use the POST /admin/api/2023-10/products/{product_id}/metafields.json endpoint to create a new metafield for a product. If you prefer GraphQL API, use the productUpdate mutation to add metafields to a product.
Hope this helps!