1

I want to always add a specific EAV attribute to the Product model whenever a Product model is loading.

As an example, I always want to include vendor_name and brand_name EAV attributes to my Product model whenever I'm loading any product model anywhere in Magento. Is there any product_before_load observer in Magento 2, so that I will be able to inject my required EAV attributes to product's model ? Or is there any other solution?

I'm in the situation that my products already loaded without those EAV attributes and I just don't want to re-load products (because of performance problems it makes (specially in catalog page, which needs to reload each product)). So I want to make sure that all Product models that I'm getting is always have those specific EAV attributes.

  • If a product is loaded it should have all the EAV attributes loaded. Do you mean you get it out from a repository or a collection? – Phoenix128_RiccardoT May 30 '16 at 6:30
  • @RiccardoT I mean I ALWAYS want some of the EAV attributes get loaded (in any situation). (even in repository or collection) – Michel Gokan May 30 '16 at 17:51
  • Use catalog_product_load_after for single product or catalog_product_collection_load_after for collection. Loading all attributes on collection sometimes lead to a very heavy page load, so be careful. – Rendy Eko Prastiyo Jan 31 '17 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.