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;








2















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!










share|improve this question






























    2















    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!










    share|improve this question


























      2












      2








      2


      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!










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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




















          1 Answer
          1






          active

          oldest

          votes


















          4














          "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) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price




          and




          INNER JOIN catalog_product_index_price AS price_index ON 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





          share|improve this answer

























            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%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









            4














            "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) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price




            and




            INNER JOIN catalog_product_index_price AS price_index ON 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





            share|improve this answer





























              4














              "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) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price




              and




              INNER JOIN catalog_product_index_price AS price_index ON 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





              share|improve this answer



























                4












                4








                4







                "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) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price




                and




                INNER JOIN catalog_product_index_price AS price_index ON 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





                share|improve this answer















                "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) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price




                and




                INNER JOIN catalog_product_index_price AS price_index ON 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






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 29 '17 at 15:37

























                answered May 9 '17 at 16:05









                sv3nsv3n

                9,95162457




                9,95162457



























                    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%2f173511%2fget-product-final-price-without-loading-entire-product%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

                    Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

                    Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?