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;
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
|
show 2 more comments
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
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
|
show 2 more comments
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
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
magento2 performance
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
|
show 2 more comments
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
|
show 2 more comments
1 Answer
1
active
oldest
votes
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
Do you have any stats to support this?
– Dominic Xigen
May 3 at 16:01
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
Do you have any stats to support this?
– Dominic Xigen
May 3 at 16:01
add a comment |
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
Do you have any stats to support this?
– Dominic Xigen
May 3 at 16:01
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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