1

I have just modified the getPrice function in app/code/core/Mage/Catalog/Model/Product/Type/Price.php to:

/**
 * Default action to get price of product
 *
 * @return decimal
 */
public function getPrice($product)
{
$product = Mage::getModel('catalog/product')->load($product->getId());
    return $product->getData('cost') * $product->getMarkup();
}

However in my category pages the price displayed is still the old price as entered in the Price attribute in the admin section.

Could someone please help me work out what I need to edit to get both prices displaying the same value again please?

Thanks.

EDIT:

Looks like it might be an issue with this code from my product/price.phtml file. Can anyone spot anything in this that might mean it isnt working?

Thanks again for any help!

<?php else: ?>
<?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, array(0, 1))): // including ?>
    <?php $weeeAmountToDisplay = $_taxHelper->displayPriceIncludingTax() ? $_weeeTaxAmountInclTaxes : $_weeeTaxAmount ?>
        <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
            <?php echo $_coreHelper->currency($_price + $weeeAmountToDisplay, true, true) ?>
        </span>
    <?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)): // show description ?>
        <span class="weee">(
            <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
                <?php echo $_weeeSeparator; ?>
                <?php echo $_weeeTaxAttribute->getName(); ?>
                : <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + ($_taxHelper->displayPriceIncludingTax() ? $_weeeTaxAttribute->getTaxAmount() : 0), true, true); ?>
                <?php $_weeeSeparator = ' + '; ?>
            <?php endforeach; ?>
        )</span>
    <?php endif; ?>
    <?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?>
        <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
            <?php echo $_coreHelper->formatPrice($_price + $_weeeTaxAmount, true) ?>
        </span>
        <span class="weee">(
            <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
                <?php echo $_weeeSeparator; ?>
                <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, true); ?>
                <?php $_weeeSeparator = ' + '; ?>
            <?php endforeach; ?>
        )</span>
    <?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?>
        <span class="regular-price"><?php echo $_coreHelper->formatPrice($_price, true) ?></span><br/>
        <?php $weeeAmountToDisplay = $_taxHelper->displayPriceIncludingTax() ? $_weeeTaxAmountInclTaxes : $_weeeTaxAmount ?>
        <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
            <span class="weee">
                <?php echo $_weeeTaxAttribute->getName(); ?>
                : <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + ($_taxHelper->displayPriceIncludingTax() ? $_weeeTaxAttribute->getTaxAmount() : 0), true, true); ?>
            </span>
        <?php endforeach; ?>
        <span class="regular-price"id="product-price-weee-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
            <?php echo $_coreHelper->currency($_price + $weeeAmountToDisplay, true, true) ?>
        </span>
    <?php else: ?>
        <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
            <?php if ($_finalPrice == $_price): ?>
                <?php echo $_coreHelper->formatPrice($_price, true) ?>
            <?php else: ?>
                <?php echo $_coreHelper->formatPrice($_finalPrice, true) ?>
            <?php endif; ?>
        </span>
    <?php endif; ?>
<?php endif; ?>

2 Answers 2

1

The category pages retrieve prices from the price index, so you have to reindex before you can see changes.

By the way, you should never edit core files, better write an own module with class rewrites. In your case it might even be suitable to create a custom product type with its own price model instead of overridding the core price model.

1
  • Thanks for the reply. I have re-indexed the site and then cleared the cache but the prices are still showing differently. I put a copy of the amended file into app/code/local/Mage/Catalog/Model/Product/Type/Price.php if that is what you meant by own module?
    – Xilitom
    Jun 24, 2016 at 15:30
1

Found the solution here: github

Hope that can help someone someday!

Your Answer

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

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