0

I have two needs for this requirement, both to show an additional price on the storefront catalog grid.

One is to show an inc. VAT figure, the other (for another site) is to show a price per square meter. I've put a very rough example below. I have the attributes created and set to be available on the storefront.

enter image description here

I'm not an accomplished Magento developer, but if I know what file to edit I can amend it in a theme and have done for other requirements.

I don't know whether I am getting the terms wrong, but I can't find a guide on how to do this anywhere. I have searched!

If anyone can help, or point me in the right direction I'd be very grateful.

Thanks!

Aaron

0

To do this is all dependant on your theme but you can modify

app/design/(your_theme) /Magento_Catalog/templates/product/list.phtml

And add

<?php /* @escapeNotVerified */ echo $_product->getResource()->getAttribute('your_attribute')->getFrontend()->getValue($_product); ?>

Just make sure that you that you make your attribute data available in the product list, this is a setting under the attribute itself

  • Thanks Dava, whereabouts would this be added to list.phtml to appear below the current price and in he same style? Also is it possible to add the name to the price field as per my mockup? Thanks again, Aaron – Aaron Nov 23 '18 at 0:36
  • If you find <?php echo $block->getProductPrice($_product) ?> in your list.phtml file should be below that – Dava Gordon Nov 23 '18 at 13:40
0

You need plugin to do this

frontend/etc/di.xml

<config>
  <type name="Magento\Catalog\Model\Product">
    <plugin name="change_product_price" type="Shapcyber\Storecaptain\Plugin\Addprice" sortOrder="1" disabled="true"/>
  </type>
</config>

/Shapcyber/Storecaptain/Plugin/Addprice.php

<?php

namespace Shapcyber\Storecaptain\Plugin;

class Addprice
{
    public function afterGetPrice(\Magento\Catalog\Model\Product $subject, $result)
    {
        return $result + 100;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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