Magento 2 - Which is faster - load product by ID via ProductRepositoryInterface, ProductFactory or object managerUnit Test for overwrite collection class in magento2Magento2: How to update the product price programaticallyMagento 2.1 Create a filter in the product grid by new attributeI want to add parent product to cart using child product id, it's configurable options in magento 2.1Having trouble exporting products from Magento 2.x. Fatal error: Uncaught Error: Call to a member function getName()Magento 2: Add a product to the cart programmaticallyMagento 2 get availabe stock of productUpdate Product programmatically - Invalid method MagentoEavModelEntityAttribute::isScopeGlobalMagento 2.2.5: Add, Update and Delete existing products Custom OptionsOverride __construct MagentoCatalogModelProduct

What is the Ancient One's mistake?

Explaining intravenous drug abuse to a small child

Antivirus for Ubuntu 18.04

Convert a huge txt-file into a dataset

What did Varys actually mean?

Where do 5 or more U.S. counties meet in a single point?

How is it believable that Euron could so easily pull off this ambush?

How to get the decimal part of a number in apex

A♭ major 9th chord in Bach is unexpectedly dissonant/jazzy

Why was Gemini VIII terminated after recovering from the OAMS thruster failure?

How could a humanoid creature completely form within the span of 24 hours?

Splitting polygons and dividing attribute value proportionally using ArcGIS Pro?

Is it safe to keep the GPU on 100% utilization for a very long time?

Do the Zhentarim fire members for killing fellow members?

My C Drive is full without reason

What is more safe for browsing the web: PC or smartphone?

Why is the blank symbol not considered part of the input alphabet of a Turing machine?

HTML folder located within IOS Image file?

Can I use LPGL3 for library and Apache 2 for "main()"?

Does restarting the SQL Services (on the machine) clear the server cache (for things like query plans and statistics)?

call() a function within its own context

What's the 2-minute timer on mobile Deutsche Bahn tickets?

In a series of books, what happens after the coming of age?

Is throwing dice a stochastic or a deterministic process?



Magento 2 - Which is faster - load product by ID via ProductRepositoryInterface, ProductFactory or object manager


Unit Test for overwrite collection class in magento2Magento2: How to update the product price programaticallyMagento 2.1 Create a filter in the product grid by new attributeI want to add parent product to cart using child product id, it's configurable options in magento 2.1Having trouble exporting products from Magento 2.x. Fatal error: Uncaught Error: Call to a member function getName()Magento 2: Add a product to the cart programmaticallyMagento 2 get availabe stock of productUpdate Product programmatically - Invalid method MagentoEavModelEntityAttribute::isScopeGlobalMagento 2.2.5: Add, Update and Delete existing products Custom OptionsOverride __construct MagentoCatalogModelProduct






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Approaching loading products from performance point of view. Assuming you want to echo out standard attribute values such as SKU, name, etc. and you are dealing with a large number of products and you are loading them within a loop (assume not a product collection). Anyone know which is the fastest method?



ObjectManager (Yes I know you're not supposed to use this method)



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);


ProductRepositoryInterface



protected $productRepository; 
...
public function __construct(
...
MagentoCatalogApiProductRepositoryInterface $productRepository
)
...
$this->productRepository= $productRepository;
...




 $product = $this->productRepository->getById($id);


ProductFactory



protected $productFactory; 
...
public function __construct(
...
MagentoCatalogModelProductFactory $productFactory
)
...
$this->productFactory = $productFactory;
...



$product = $this->productFactory->create()->load($id);









share|improve this question






















  • I'm assuming MagentoCatalogModelProductRepository::getById is the same speed if not slower as extends from ProductRepositoryInterface. But could be wrong?

    – Dominic Xigen
    May 3 at 16:06






  • 1





    Don't use $this->productFactory->create()->load($id);, this load method is deprecated.

    – Sohel Rana
    May 3 at 16:07











  • MagentoCatalogModelProductRepository::getById has caching. Anyone know whether this or MagentoCatalogApiProductRepositoryInterface::getById is the prefered method?

    – Dominic Xigen
    May 3 at 16:10












  • MagentoCatalogApiProductRepositoryInterface::getById -> This is prefered method.

    – Sohel Rana
    May 3 at 16:15






  • 1





    Yes, it is. It has param like $editMode, if you pass this false which is faster. If you need more product then use getList method.

    – Sohel Rana
    May 3 at 16:42

















1















Approaching loading products from performance point of view. Assuming you want to echo out standard attribute values such as SKU, name, etc. and you are dealing with a large number of products and you are loading them within a loop (assume not a product collection). Anyone know which is the fastest method?



ObjectManager (Yes I know you're not supposed to use this method)



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);


ProductRepositoryInterface



protected $productRepository; 
...
public function __construct(
...
MagentoCatalogApiProductRepositoryInterface $productRepository
)
...
$this->productRepository= $productRepository;
...




 $product = $this->productRepository->getById($id);


ProductFactory



protected $productFactory; 
...
public function __construct(
...
MagentoCatalogModelProductFactory $productFactory
)
...
$this->productFactory = $productFactory;
...



$product = $this->productFactory->create()->load($id);









share|improve this question






















  • I'm assuming MagentoCatalogModelProductRepository::getById is the same speed if not slower as extends from ProductRepositoryInterface. But could be wrong?

    – Dominic Xigen
    May 3 at 16:06






  • 1





    Don't use $this->productFactory->create()->load($id);, this load method is deprecated.

    – Sohel Rana
    May 3 at 16:07











  • MagentoCatalogModelProductRepository::getById has caching. Anyone know whether this or MagentoCatalogApiProductRepositoryInterface::getById is the prefered method?

    – Dominic Xigen
    May 3 at 16:10












  • MagentoCatalogApiProductRepositoryInterface::getById -> This is prefered method.

    – Sohel Rana
    May 3 at 16:15






  • 1





    Yes, it is. It has param like $editMode, if you pass this false which is faster. If you need more product then use getList method.

    – Sohel Rana
    May 3 at 16:42













1












1








1








Approaching loading products from performance point of view. Assuming you want to echo out standard attribute values such as SKU, name, etc. and you are dealing with a large number of products and you are loading them within a loop (assume not a product collection). Anyone know which is the fastest method?



ObjectManager (Yes I know you're not supposed to use this method)



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);


ProductRepositoryInterface



protected $productRepository; 
...
public function __construct(
...
MagentoCatalogApiProductRepositoryInterface $productRepository
)
...
$this->productRepository= $productRepository;
...




 $product = $this->productRepository->getById($id);


ProductFactory



protected $productFactory; 
...
public function __construct(
...
MagentoCatalogModelProductFactory $productFactory
)
...
$this->productFactory = $productFactory;
...



$product = $this->productFactory->create()->load($id);









share|improve this question














Approaching loading products from performance point of view. Assuming you want to echo out standard attribute values such as SKU, name, etc. and you are dealing with a large number of products and you are loading them within a loop (assume not a product collection). Anyone know which is the fastest method?



ObjectManager (Yes I know you're not supposed to use this method)



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);


ProductRepositoryInterface



protected $productRepository; 
...
public function __construct(
...
MagentoCatalogApiProductRepositoryInterface $productRepository
)
...
$this->productRepository= $productRepository;
...




 $product = $this->productRepository->getById($id);


ProductFactory



protected $productFactory; 
...
public function __construct(
...
MagentoCatalogModelProductFactory $productFactory
)
...
$this->productFactory = $productFactory;
...



$product = $this->productFactory->create()->load($id);






magento2 performance






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 3 at 15:39









Dominic XigenDominic Xigen

688




688












  • I'm assuming MagentoCatalogModelProductRepository::getById is the same speed if not slower as extends from ProductRepositoryInterface. But could be wrong?

    – Dominic Xigen
    May 3 at 16:06






  • 1





    Don't use $this->productFactory->create()->load($id);, this load method is deprecated.

    – Sohel Rana
    May 3 at 16:07











  • MagentoCatalogModelProductRepository::getById has caching. Anyone know whether this or MagentoCatalogApiProductRepositoryInterface::getById is the prefered method?

    – Dominic Xigen
    May 3 at 16:10












  • MagentoCatalogApiProductRepositoryInterface::getById -> This is prefered method.

    – Sohel Rana
    May 3 at 16:15






  • 1





    Yes, it is. It has param like $editMode, if you pass this false which is faster. If you need more product then use getList method.

    – Sohel Rana
    May 3 at 16:42

















  • I'm assuming MagentoCatalogModelProductRepository::getById is the same speed if not slower as extends from ProductRepositoryInterface. But could be wrong?

    – Dominic Xigen
    May 3 at 16:06






  • 1





    Don't use $this->productFactory->create()->load($id);, this load method is deprecated.

    – Sohel Rana
    May 3 at 16:07











  • MagentoCatalogModelProductRepository::getById has caching. Anyone know whether this or MagentoCatalogApiProductRepositoryInterface::getById is the prefered method?

    – Dominic Xigen
    May 3 at 16:10












  • MagentoCatalogApiProductRepositoryInterface::getById -> This is prefered method.

    – Sohel Rana
    May 3 at 16:15






  • 1





    Yes, it is. It has param like $editMode, if you pass this false which is faster. If you need more product then use getList method.

    – Sohel Rana
    May 3 at 16:42
















I'm assuming MagentoCatalogModelProductRepository::getById is the same speed if not slower as extends from ProductRepositoryInterface. But could be wrong?

– Dominic Xigen
May 3 at 16:06





I'm assuming MagentoCatalogModelProductRepository::getById is the same speed if not slower as extends from ProductRepositoryInterface. But could be wrong?

– Dominic Xigen
May 3 at 16:06




1




1





Don't use $this->productFactory->create()->load($id);, this load method is deprecated.

– Sohel Rana
May 3 at 16:07





Don't use $this->productFactory->create()->load($id);, this load method is deprecated.

– Sohel Rana
May 3 at 16:07













MagentoCatalogModelProductRepository::getById has caching. Anyone know whether this or MagentoCatalogApiProductRepositoryInterface::getById is the prefered method?

– Dominic Xigen
May 3 at 16:10






MagentoCatalogModelProductRepository::getById has caching. Anyone know whether this or MagentoCatalogApiProductRepositoryInterface::getById is the prefered method?

– Dominic Xigen
May 3 at 16:10














MagentoCatalogApiProductRepositoryInterface::getById -> This is prefered method.

– Sohel Rana
May 3 at 16:15





MagentoCatalogApiProductRepositoryInterface::getById -> This is prefered method.

– Sohel Rana
May 3 at 16:15




1




1





Yes, it is. It has param like $editMode, if you pass this false which is faster. If you need more product then use getList method.

– Sohel Rana
May 3 at 16:42





Yes, it is. It has param like $editMode, if you pass this false which is faster. If you need more product then use getList method.

– Sohel Rana
May 3 at 16:42










1 Answer
1






active

oldest

votes


















1














In this scenario we can compare only two option ProductRepositoryInterface
and Product Factory. So these two options the ProductRepositoryInterface is faster then Product Factory the reason behind that is ProductRepositoryInterface is getting the Data using API






share|improve this answer

























  • Do you have any stats to support this?

    – Dominic Xigen
    May 3 at 16:01











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273381%2fmagento-2-which-is-faster-load-product-by-id-via-productrepositoryinterface%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














In this scenario we can compare only two option ProductRepositoryInterface
and Product Factory. So these two options the ProductRepositoryInterface is faster then Product Factory the reason behind that is ProductRepositoryInterface is getting the Data using API






share|improve this answer

























  • Do you have any stats to support this?

    – Dominic Xigen
    May 3 at 16:01















1














In this scenario we can compare only two option ProductRepositoryInterface
and Product Factory. So these two options the ProductRepositoryInterface is faster then Product Factory the reason behind that is ProductRepositoryInterface is getting the Data using API






share|improve this answer

























  • Do you have any stats to support this?

    – Dominic Xigen
    May 3 at 16:01













1












1








1







In this scenario we can compare only two option ProductRepositoryInterface
and Product Factory. So these two options the ProductRepositoryInterface is faster then Product Factory the reason behind that is ProductRepositoryInterface is getting the Data using API






share|improve this answer















In this scenario we can compare only two option ProductRepositoryInterface
and Product Factory. So these two options the ProductRepositoryInterface is faster then Product Factory the reason behind that is ProductRepositoryInterface is getting the Data using API







share|improve this answer














share|improve this answer



share|improve this answer








edited May 3 at 16:02

























answered May 3 at 15:58









Asad KhanAsad Khan

44213




44213












  • Do you have any stats to support this?

    – Dominic Xigen
    May 3 at 16:01

















  • Do you have any stats to support this?

    – Dominic Xigen
    May 3 at 16:01
















Do you have any stats to support this?

– Dominic Xigen
May 3 at 16:01





Do you have any stats to support this?

– Dominic Xigen
May 3 at 16:01

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273381%2fmagento-2-which-is-faster-load-product-by-id-via-productrepositoryinterface%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림