3

In my store I have some grouped product that they show in a table and I change it to show the simple products of a group product in a drop down list. Now I want to get price of each simple product in option tag that I can use it for show the price in some where that I want.

Now I test this code for get the price but it doesn't show any thing. How can I get the price and tier price of product?

<select id="productsHolder">
    <?php if ($_hasAssociatedProducts): ?>
    <?php foreach ($_associatedProducts as $_item): ?>
        <?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
                <option value="<?php echo $this->escapeHtml($_item->getName()) ?>" 
                        price="<?php echo $this->getPriceHtml($_item, true) ?>"
                        tierprice="<?php echo $this->getTierPriceHtml($_item) ?>">
                        <?php echo $this->escapeHtml($_item->getName()) ?>
                </option>
    <?php endforeach; ?>
</select>

Also I try <?php echo $_product->getPrice(); ?> but it doesn't work.

4 Answers 4

2

=> Magento 2 :

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$registry = $objectManager->get('\Magento\Framework\Registry');
$currentProduct = $registry->registry('current_product');
echo $currentProduct->getFinalPrice();

=> Magento 1 :

$product_id = Mage::registry('current_product')->getPrice();
0

try <?php echo $this->escapeHtml($_item->getPrice()) ?>

2
  • And about teirprice?
    – Elham Gdz
    Commented Jul 29, 2015 at 11:57
  • I would assume that the tier price is not loaded Commented Jul 29, 2015 at 12:45
0

This should work for the tier price also

$custom = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->sku); var_dump($custom->getTierPrice());
0

I haven't tried it, but you can var_dump $_item->debug() or $_item->getData() and see if tier price is included.

Also you can try $_item->getTierPrice().

3
  • Suggesting ideas that you haven't tested or that you are unsure if they would even be answers should not be submitted as answers, but rather as comments on the original question. This helps keep the quality of answers high and helps to ensure good Q / A ratio metrics. Commented Apr 28, 2016 at 1:26
  • I am not able to add comment because i haven't enaugj points to add comment Commented Apr 28, 2016 at 1:28
  • I understand how frustrating that can be, Ledian. Perhaps you might consider focusing your efforts on submitting answers that you can test more fully? I will remove the downvote if you update your answer and provide additional information that illustrates how you reproduced the issue and then used the steps to determine a solution. The important thing is that an answer should actually answer the submitter's question. Commented Apr 28, 2016 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.