So I currently have multiple different product types that have varying fields. I was able to fetch all products using EntityTypeManager the following way:
$productStorage = \Drupal::entityTypeManager()->getStorage('commerce_product'); $ids = $productStorage->getQuery()->execute(); $allProducts = $productStorage->loadMultiple($ids);
This works quite well, and I see how this can be used to execute more complicated queries. However, I'd like to now get a certain product (perhaps based off the product_id). I saw a previous post showing that a dynamic query is faster than an EntityFieldQuery. So if for example my custom api call (my drupal is communicating with a frontend server) gets a request for a certain product by product_id and product type, how can I determine the fields of the product type with which I can then create a dynamic database query to get the product and the field values that go along with it? I read somewhere that this information is stored in the config table in the database and shouldn't really be queried, which is why I'm asking this question.
Thanks for the help in advance, and let me know if there's anything unclear about my post!