Get product FINAL price without loading entire product The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)What is faster - getting raw attribute value or use collection?How can I delete configurable product attributes?Display product price without loading whole productObtain final price(s) of item(s) after promotion rules applied?Get final price of configurable optionUse final price in addFieldToFilterMagento1.9 - select products with similar price from product categoriesMagento 1.9 custom soap api module cannot get product final price from collectionHow to check final price or special price is valid or expire on magento 1.9Magento2 Apply catalogrule on final price instead original priceHow to get final price of a product by rest API?
Was credit for the black hole image misappropriated?
Is an up-to-date browser secure on an out-of-date OS?
What can I do if neighbor is blocking my solar panels intentionally?
Why not take a picture of a closer black hole?
Word to describe a time interval
Homework question about an engine pulling a train
Mortgage adviser recommends a longer term than necessary combined with overpayments
Store Dynamic-accessible hidden metadata in a cell
Working through the single responsibility principle (SRP) in Python when calls are expensive
Define a list range inside a list
Accepted by European university, rejected by all American ones I applied to? Possible reasons?
How many Rusted Keys do you need to get red items most of the time?
Why can I use a list index as an indexing variable in a for loop?
Why doesn't shell automatically fix "useless use of cat"?
How to determine omitted units in a publication
Identify 80s or 90s comics with ripped creatures (not dwarves)
Why did Peik Lin say, "I'm not an animal"?
Can the Right Ascension and Argument of Perigee of a spacecraft's orbit keep varying by themselves with time?
Why doesn't a hydraulic lever violate conservation of energy?
Nested ellipses in tikzpicture: Chomsky hierarchy
Is this wall load bearing? Blueprints and photos attached
Does Parliament hold absolute power in the UK?
What to do when moving next to a bird sanctuary with a loosely-domesticated cat?
how can a perfect fourth interval be considered either consonant or dissonant?
Get product FINAL price without loading entire product
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)What is faster - getting raw attribute value or use collection?How can I delete configurable product attributes?Display product price without loading whole productObtain final price(s) of item(s) after promotion rules applied?Get final price of configurable optionUse final price in addFieldToFilterMagento1.9 - select products with similar price from product categoriesMagento 1.9 custom soap api module cannot get product final price from collectionHow to check final price or special price is valid or expire on magento 1.9Magento2 Apply catalogrule on final price instead original priceHow to get final price of a product by rest API?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I can get product attributes efficiently without loading the entire product by using:
Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'attribute_code', $storeId);
However, I can only do this with the price 'attribute, since final_price is technically not an attribute. Since I'm grabbing a few hundred products on one page load, and the only data I need is the product's final price, doing this is very inefficient:
foreach($productIds as $productId)
$finalPrice = Mage::getModel('catalog/product')->load($productId)->getFinalPrice();
....
Since I'm loading the entire product. If anybody can suggest a more efficient way, I would really appreciate it. Cheers!
magento-1.9 attributes price product-collection special-price
add a comment |
I can get product attributes efficiently without loading the entire product by using:
Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'attribute_code', $storeId);
However, I can only do this with the price 'attribute, since final_price is technically not an attribute. Since I'm grabbing a few hundred products on one page load, and the only data I need is the product's final price, doing this is very inefficient:
foreach($productIds as $productId)
$finalPrice = Mage::getModel('catalog/product')->load($productId)->getFinalPrice();
....
Since I'm loading the entire product. If anybody can suggest a more efficient way, I would really appreciate it. Cheers!
magento-1.9 attributes price product-collection special-price
add a comment |
I can get product attributes efficiently without loading the entire product by using:
Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'attribute_code', $storeId);
However, I can only do this with the price 'attribute, since final_price is technically not an attribute. Since I'm grabbing a few hundred products on one page load, and the only data I need is the product's final price, doing this is very inefficient:
foreach($productIds as $productId)
$finalPrice = Mage::getModel('catalog/product')->load($productId)->getFinalPrice();
....
Since I'm loading the entire product. If anybody can suggest a more efficient way, I would really appreciate it. Cheers!
magento-1.9 attributes price product-collection special-price
I can get product attributes efficiently without loading the entire product by using:
Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'attribute_code', $storeId);
However, I can only do this with the price 'attribute, since final_price is technically not an attribute. Since I'm grabbing a few hundred products on one page load, and the only data I need is the product's final price, doing this is very inefficient:
foreach($productIds as $productId)
$finalPrice = Mage::getModel('catalog/product')->load($productId)->getFinalPrice();
....
Since I'm loading the entire product. If anybody can suggest a more efficient way, I would really appreciate it. Cheers!
magento-1.9 attributes price product-collection special-price
magento-1.9 attributes price product-collection special-price
edited Apr 9 at 6:10
Muhammad Anas
607318
607318
asked May 8 '17 at 19:45
Shaquille Adam Jessop DavisShaquille Adam Jessop Davis
1114
1114
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
"a more efficient way" is to use product collcections where final price is already add to. Some numbers here: What is faster - getting raw attribute value or use collection?
Using ->addFinalPrice() will add something like this to collection query ...
,
price_index.price,price_index.tax_class_id,price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) ASminimal_price,price_index.min_price,price_index.max_price,price_index.tier_price
and
INNER JOIN
catalog_product_index_priceASprice_indexON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
I'd us a colletion like
$collection = Mage::getResourceModel('catalog/product_collection')
->addIdFilter($productIds)
->addFinalPrice();
foreach ($collection as $product)
$finalPrices[] = $product->getFinalPrice();
- Total Incl. Wall Time (microsec): 2,131,092 microsecs
- Total Incl. CPU (microsecs): 2,109,925 microsecs
- Total Incl. MemUse (bytes): 4,776,976 bytes
- Total Incl. PeakMemUse (bytes): 4,829,112 bytes
- Number of Function Calls: 103,275
compared to
foreach($productIds as $productId)
$finalPrices[] = Mage::getModel('catalog/product')->load($productId)->getFinalPrice();
- Total Incl. Wall Time (microsec): 116,555,318 microsecs
- Total Incl. CPU (microsecs): 114,323,845 microsecs
- Total Incl. MemUse (bytes): 22,853,768 bytes
- Total Incl. PeakMemUse (bytes): 23,126,448 bytes
- Number of Function Calls: 5,465,676
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%2f173511%2fget-product-final-price-without-loading-entire-product%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
"a more efficient way" is to use product collcections where final price is already add to. Some numbers here: What is faster - getting raw attribute value or use collection?
Using ->addFinalPrice() will add something like this to collection query ...
,
price_index.price,price_index.tax_class_id,price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) ASminimal_price,price_index.min_price,price_index.max_price,price_index.tier_price
and
INNER JOIN
catalog_product_index_priceASprice_indexON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
I'd us a colletion like
$collection = Mage::getResourceModel('catalog/product_collection')
->addIdFilter($productIds)
->addFinalPrice();
foreach ($collection as $product)
$finalPrices[] = $product->getFinalPrice();
- Total Incl. Wall Time (microsec): 2,131,092 microsecs
- Total Incl. CPU (microsecs): 2,109,925 microsecs
- Total Incl. MemUse (bytes): 4,776,976 bytes
- Total Incl. PeakMemUse (bytes): 4,829,112 bytes
- Number of Function Calls: 103,275
compared to
foreach($productIds as $productId)
$finalPrices[] = Mage::getModel('catalog/product')->load($productId)->getFinalPrice();
- Total Incl. Wall Time (microsec): 116,555,318 microsecs
- Total Incl. CPU (microsecs): 114,323,845 microsecs
- Total Incl. MemUse (bytes): 22,853,768 bytes
- Total Incl. PeakMemUse (bytes): 23,126,448 bytes
- Number of Function Calls: 5,465,676
add a comment |
"a more efficient way" is to use product collcections where final price is already add to. Some numbers here: What is faster - getting raw attribute value or use collection?
Using ->addFinalPrice() will add something like this to collection query ...
,
price_index.price,price_index.tax_class_id,price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) ASminimal_price,price_index.min_price,price_index.max_price,price_index.tier_price
and
INNER JOIN
catalog_product_index_priceASprice_indexON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
I'd us a colletion like
$collection = Mage::getResourceModel('catalog/product_collection')
->addIdFilter($productIds)
->addFinalPrice();
foreach ($collection as $product)
$finalPrices[] = $product->getFinalPrice();
- Total Incl. Wall Time (microsec): 2,131,092 microsecs
- Total Incl. CPU (microsecs): 2,109,925 microsecs
- Total Incl. MemUse (bytes): 4,776,976 bytes
- Total Incl. PeakMemUse (bytes): 4,829,112 bytes
- Number of Function Calls: 103,275
compared to
foreach($productIds as $productId)
$finalPrices[] = Mage::getModel('catalog/product')->load($productId)->getFinalPrice();
- Total Incl. Wall Time (microsec): 116,555,318 microsecs
- Total Incl. CPU (microsecs): 114,323,845 microsecs
- Total Incl. MemUse (bytes): 22,853,768 bytes
- Total Incl. PeakMemUse (bytes): 23,126,448 bytes
- Number of Function Calls: 5,465,676
add a comment |
"a more efficient way" is to use product collcections where final price is already add to. Some numbers here: What is faster - getting raw attribute value or use collection?
Using ->addFinalPrice() will add something like this to collection query ...
,
price_index.price,price_index.tax_class_id,price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) ASminimal_price,price_index.min_price,price_index.max_price,price_index.tier_price
and
INNER JOIN
catalog_product_index_priceASprice_indexON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
I'd us a colletion like
$collection = Mage::getResourceModel('catalog/product_collection')
->addIdFilter($productIds)
->addFinalPrice();
foreach ($collection as $product)
$finalPrices[] = $product->getFinalPrice();
- Total Incl. Wall Time (microsec): 2,131,092 microsecs
- Total Incl. CPU (microsecs): 2,109,925 microsecs
- Total Incl. MemUse (bytes): 4,776,976 bytes
- Total Incl. PeakMemUse (bytes): 4,829,112 bytes
- Number of Function Calls: 103,275
compared to
foreach($productIds as $productId)
$finalPrices[] = Mage::getModel('catalog/product')->load($productId)->getFinalPrice();
- Total Incl. Wall Time (microsec): 116,555,318 microsecs
- Total Incl. CPU (microsecs): 114,323,845 microsecs
- Total Incl. MemUse (bytes): 22,853,768 bytes
- Total Incl. PeakMemUse (bytes): 23,126,448 bytes
- Number of Function Calls: 5,465,676
"a more efficient way" is to use product collcections where final price is already add to. Some numbers here: What is faster - getting raw attribute value or use collection?
Using ->addFinalPrice() will add something like this to collection query ...
,
price_index.price,price_index.tax_class_id,price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) ASminimal_price,price_index.min_price,price_index.max_price,price_index.tier_price
and
INNER JOIN
catalog_product_index_priceASprice_indexON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
I'd us a colletion like
$collection = Mage::getResourceModel('catalog/product_collection')
->addIdFilter($productIds)
->addFinalPrice();
foreach ($collection as $product)
$finalPrices[] = $product->getFinalPrice();
- Total Incl. Wall Time (microsec): 2,131,092 microsecs
- Total Incl. CPU (microsecs): 2,109,925 microsecs
- Total Incl. MemUse (bytes): 4,776,976 bytes
- Total Incl. PeakMemUse (bytes): 4,829,112 bytes
- Number of Function Calls: 103,275
compared to
foreach($productIds as $productId)
$finalPrices[] = Mage::getModel('catalog/product')->load($productId)->getFinalPrice();
- Total Incl. Wall Time (microsec): 116,555,318 microsecs
- Total Incl. CPU (microsecs): 114,323,845 microsecs
- Total Incl. MemUse (bytes): 22,853,768 bytes
- Total Incl. PeakMemUse (bytes): 23,126,448 bytes
- Number of Function Calls: 5,465,676
edited Jul 29 '17 at 15:37
answered May 9 '17 at 16:05
sv3nsv3n
9,95162457
9,95162457
add a comment |
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%2f173511%2fget-product-final-price-without-loading-entire-product%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