Hi I want to add "VAT excl " text after the product price in single product page . How can i do this . Which file i need to edit . Please suggest the correct path
app/design/frontend/mythemes/default/Magento_Catalog/templates/
Method - 1: If you want to display custom text only in product view page, then create catalog_product_view.xml in your custom theme
app/design/frontend/Vendor/theme/Magento_Catalog/layout/catalog_product_view.xml
<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.main">
<block class="Magento\Framework\View\Element\Template" name="custom.text" template="Magento_Catalog::view/customtext.phtml" after="product.info.price"/>
</referenceContainer>
</body>
</page>
Now create customtext.phtml and add your custom text
app/design/frontend/Vendor/theme/Magento_Catalog/templates/view/customtext.phtml
Now flush the cache and check
Method - 2: If you want to display custom text after price at everywhere then override final_price.phtml
FROM
vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml
TO
app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/price/final_price.phtml
Method - 3: Last and the most simple way to do it with CSS
.product-info-price .price:after {
content: 'Custom Text';
}
Related
I have two custom magento blocks called "exe2" and "example".
The exe2 block gets the contents of the example block using the getChildHtml function, but it keeps just returning empty strings to me and only the exe2 contents make it to the screen.
Here is my code my code:
exe2 xml file:
<layout version = "0.1.0">
<test_example_view>
<block type = "exemplum_mod2/exe2" name = "exemplum.mod2.exe2" template="exemplum/mod2/exe2.phtml">
<reference name = "exemplum.mod2.exe2">
<block type="exemplum/example" name="exemplum.example" template="exemplum/example1/example.phtml" />
</reference>
</block>
</test_example_view>
example xml file
<layout version="0.1.0">
<default>
<block type="exemplum/example" name="exemplum.example" template="exemplum/example1/example.phtml" />
</default>
Here is the exe2 phtml file that has the getChildHtml call in it:
<h1> 2nd </h1>
<?php
echo $this->getMessage();
echo $this->getChildHtml("exemplum.mod2.exe2");
?>
hello
example.phtml file:
<h1>Hello there</h1>
And finally heres the controller file that loads the blocks:
<?php
class exemplum_example1_ExampleController extends Mage_Core_Controller_Front_Action{
public function viewAction(){
$this->loadLayout();
$block = $this->getLayout()->createBlock('exemplum_mod2/exe2');
$block->setTemplate("exemplum/mod2/exe2.phtml");
$this->getLayout()->getBlock('content')->append($block);
$this->renderLayout();
}
}
What is the correct way to add one block as the child block of a another block in the xml file? Every solution that i found on google didn't seem to work in my case so what am i doing wrong here?
I would like to add a notification in the Admin area, something like 'Latest message' bar but under it.
I have tried using the AdminhtmlNotification module but that only adds a new message into the 'Latest message' queue and if my message is not the last one in is only displayed in the grid.
Thanks in advance for your help,
Denis Rendler
All you have to do is to add your own block under notifications handler of adminhtml layout.
<?xml version="1.0"?>
<layout>
<default>
<reference name="notifications">
<block type="extension/adminhtml_notifications" name="extension_notifications" template="extension/notification.phtml"/>
</reference>
</default>
</layout>
And then create and edit the file extension/notification.phtml:
<?php if ($message = $this->getMessage()) : ?>
<div class="notification-global">Hello!</div>
<?php endif; ?>
For more information, check this article:
https://www.openstream.ch/developer-blog/adding-magento-admin-notifications-to-your-extension/
I am creating a module that will have its own page at mysite.com/memymodule/index/index
I want to add functionality from a template file from at templates/me/template.phtml
I have an index controller like this:
<?php
class me_mymodule_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
}
?>
I have a layout update mymodule.xml that looks like this:
<?xml version="1.0"?>
<layout version="0.1.0">
<mymodule_index_index>
<reference name="content">
<block type="core/template" name="me.mymodule" template="me/template.phtml" />
</reference>
</mymodule_index_index>
</layout>
The frontName of the module is mymodule
When the page renders the content block is completely empty and the content of template.phtml is completely ignored.
Help much appreciated :-)
Try this Code within your Controller's Action -
var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
exit("Your Layout Path is ".__LINE__." in ".__FILE__);
This code tells you about the Tag which you need to create within Layout.xml.
Also check Config.xml that the Layout Update Section is correctly defined or not.
Hope it'll be beneficial for you.
THANKS
I am showing only a single product on home page. I want to show the product name in page title. How can I do this?
You have multiple ways of doing this:
In your module's layout xml file (located at app/design/frontend/[package]/[theme]/layout/{your_file_name}.xml):
<reference name="head">
<action method="setTitle"><title>Title text here</title></action>
</reference>
The bad thing here is that you can't set tittle "on the fly".
In your block file (_prepareLayout() method is a good place):
public function _prepareLayout()
{
$headBlock = $this->getLayout()->getBlock('head');
$headBlock->setTitle('Title text here');
return parent::_prepareLayout();
}
Anywhere else:
Mage::app()->getLayout()->getBlock('head')->setTitle('Title text here');
Useful link - Layouts, Blocks and Templates
If Im on this page:
http:///checkout/cart/
With products in my cart I would like to display the tiered pricing, the same that is shown on the item page, if available.
My attempt was add
<checkout_cart_index>
<block type="catalog/product_view" name="product.tierprices" as="tierprices" template="catalog/product/view/tierprices.phtml"/>
</checkout_cart_index>
to my xml file and add
<?php echo $this->getChildHtml('tierprices') ?>
to
\app\design\frontend\enterprise\<mytemplate>\template\checkout\cart\item\default.phtml
Doesn’t do anything - any further suggestions?
It seems impossible to easily change layout. You need to modify item renderer and add tier price displaying manually. To fetch list of available tier prices you need to get price model. You can get it from product model
$product->getPriceModel()
or if don't have product model try the following code
Mage::getSingleton('catalog/product_type')->priceFactory($productTypeId)
Quote item contains product type information.
When you have price model just call method getTierPrice() to get all tier prices as array.
$priceModel->getTierPrice()
You could edit the .phtml file and adding the $this->getTierPrices($_product);//or$this->getTierPrices($_item); if you simply want to display the tier prices of products.
Do note that the getTierPrices() only works when being on the product list or product view page, so you would need to copy the getTierPrices() method that can be found inside the List.php to your custom module.
This should give you an idea what needs to be done.
layout file
<?xml version="1.0"?>
<layout version="0.1.0">
<checkout_cart_index>
<reference name="additional.product.info">
<block type="LokeyCoding_Cart/TierPrice" name="additional.product.info.tierprice" />
</reference>
</checkout_cart_index>
</version>
block file
<?php
class LokeyCoding_Cart_Block_TierPrice extends Mage_Core_Block_Abstract
{
protected function _toHtml()
{
$parent = $this->getParentBlock();
if ($parent) {
$item = $parent->getItem();
if ($item instanceof Mage_Sales_Model_Quote_Item) {
return $item->getProduct()->getTierPriceHtml();
}
}
return '';
}
}