How to change currency code abbrevation with currency symbol in Magento - magento

I have a slight problem with Magento here.
If you look at this page
MY DEMO PAGE
You will see RED BUTON with title KUPI and price as 9 BAM.
BAM is my currency code, not my currency symbol. I need to replace this "BAM" with "KM".
On checkout everything is fine, all prices are in "KM" not in "BAM".
Code of this part (with button KUPI) is:
<div class="pull-right" id="deal-show-vitals-buy">
<a onclick="submitform();" data-deal_id="<?php echo $_product->getId();?>" href="#"
data-toggle="modal" class="btn btn-large btn-g font-large"
id="buy-button">
<strong>KUPI</strong> <?php echo $this->getPriceCurrency($_product->getPrice()); ?> </a>
</div>
Problem is in this part of code, i think:
<?php echo $this->getPriceCurrency($_product->getPrice()); ?>
Please, any help appreciated

The core helper ( Mage::helper('core') ) has a method in it which you can use to format the currency.
<?php echo Mage::helper('core')->currency($_product->getPrice()) ?>
As an alternative, you are able to get the currency symbol as a stand alone option as well.
$symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
echo $symbol;
My recommendation is to use the first option (the core helper) since it is the primary purpose of using helpers.
References
Magento Core Helper Documentation

Related

Joomla : render custom fields in search results

Is it possible to display core custom fields in search results ? I can add custom fields in template override for article view like this :
<?php echo $this->item->jcfields[1]->value; ?>
It works fine for com_content but it doesn't display anything in search results (com_search).
Is there a way to render my custom fields in the search results ?
Thank you.
You can create a template overwrite for the com search component like other overwrites by creating a 'html/com_content/com_search/search' folder in your current template.
In this you copy the content of /components/com_search/views/search/tmpl
You can find a description with examples here: https://docs.joomla.org/Customising_the_Smart_Search_results_page
This is targeted at Smart Search (com_finder), however you can follow this by replacing com_finder for com_search.
Then you customize and add the custom fields in the file: default_results.php in your overwrite file.
Please note that the custom fields are a string in the $result object
["jcfields"]=>
string(26) "Custom Field,Search123,1,2"
echo "My fields: ".$result->jcfields;
If you want to do this for Smart Search in Joomla 4, here is the solution.
Create a template override of the file: components/com_finder/tmpl/search/default_result.php
At the start of the file (after line 20), add this code:
// Creates an array with all the CF of the current article.
$articleCustomFields = Joomla\Component\Fields\Administrator\Helper\FieldsHelper::getFields('com_content.article', $this->result, true);
// Creates an associative array using the custom field id as a key.
$articleCustomFields = \Joomla\Utilities\ArrayHelper::pivot($articleCustomFields, 'id');
Then print the custom fields in the page:
<ul class="fields-container">
<?php
// We are using the custom fields with ids 10 and 3
if (!empty($articleCustomFields[10]->value)) : ?>
<li class="field-entry">
<span class="field-label"><?= $articleCustomFields[10]->label ?>:</span>
<span class="field-value"><?= $articleCustomFields[10]->value; ?></span>
</li>
<?php
endif; ?>
<?php
if (!empty($articleCustomFields[3]->value)) : ?>
<li class="field-entry">
<span class="field-label"><?= $articleCustomFields[3]->label ?>:</span>
<span class="field-value"><?= $articleCustomFields[3]->value; ?></span>
</li>
<?php
endif; ?>
</ul>
If you are looking for a complete tutorial, please have a look at:
https://blue-coder.com/help/blog/adding-custom-fields-in-the-search-results

Magento shows attribute if value is left blank

I have a drop down magento attribute for warranty_labour. I'm pulling in the attribute using my themes product/view.phtml and then attaching an icon to show what warranty you get.
Ive used this code which successfully works:
<?php $warranty=$_product->getAttributeText('warranty_labour'); echo '<img style="padding-top: 10px;" src="/images/warrantylabour/'.str_replace(' ', '_',$warranty).'.png" alt="'.$warranty.'">'; ?>
The problem I find when a product doesn't have a warranty attribute set (left blank on the backend) I still get the code inserted on to the product source code on the frontend like this:
<img style="pad`ding-top: 10px;" src="/images/warrantylabour/.png" alt="">`
Is there a way I can stop this happening when a value isn't set in the attribute?
Don't forget logic! :-) Just test that $warranty has a value Using typical Magento template conventions:
<?php if($warranty=$_product->getAttributeText('warranty_labour')): ?>
<?php echo sprintf('<img style="padding-top: 10px;" src="/images/warrantylabour/%s.png" alt="%s"/>', str_replace(' ', '_',$warranty),$warranty) ?>
<?php endif; ?>
This kind of syntax might justify encapsulating this logic and string building into a helper method, I think.

open a modal windows in a server

Hi everyone I have a modal windows in joomla 3.0!
I pass the router to javascript like this
<?php $link =JURI::root().'index.php?option=com_projects&view=proyectos&format=raw&task=todosProyecto&id='. $item->id;?>
<li class="item" data-id="id-<?php echo $item->id ?>" data-type="<?php echo $item->categoria ?>">
<a href="#modal" id="<?php echo $link;?>" role="<?php echo $item->id ?>" class="picture" data-toggle="modal">
<img src="<?php echo JURI::root()?><?php echo $item->imagen_portada; ?>"/></a>
<p class="titulo"><?php echo $item->nombre; ?></p>
<p> <?php echo $item->municipio; ?>(<?php echo $item->pais; ?>)<br><?php echo $item->year; ?>
</p>
In local when I open the modal windows it work well, but in the server the modal windows show me the index.php view of this component.
I think that my problem is here, when I take the request for the model I have this.
public function elegirSeleccionados(){
$this->pagination = $this->get('pagination');
$this->items = $this->get('recientes');
$this->list = $this->get('list');
parent::display();
}
But $this->get('list'); is null so I have to asigned a null value to list.
I changed by that..
$this->list = $this->items;
but dont work to!
Any idea!!!
Where is this code?
First part looks like a Layout (views\proyectos\tmpl\default.php) and the second one like a View (views\proyectos\view.html.php).
If it is so, I'd say you are not really loading items in View from the Model. Try using $this->items = $this->get('Items');
But this doesn't explain different results on server and local host.
Hi everyone I solved the problem... the name of my view hava a Camelcase for example itemId and joomla try to find itemid, so donĀ“t find the view and show the default view in the modal.
So I change the name of file without camelCase and now work.!

How to remove time from dateTime in kunena1.7

I use kunena in my site and I want remove time from datetime in latest post by user in main page or in post page.
I delete %H:%i from its variable in language file but time is shown still.
How can I remove this?
Edit code of kunena core.
For example in this path:
components/com_kunena/template/yourTemplate/view/message.php
I edited this:
<span class="kmsgdate kmsgdate-left" title="<?php echo CKunenaTimeformat::showDate($this->msg->time, 'config_post_dateformat_hover') ?>">
<?php echo CKunenaTimeformat::showDate($this->msg->time, 'config_post_dateformat'); ?>
</span>
To:
<span class="kmsgdate kmsgdate-left" title="<?php echo CKunenaTimeformat::showDate($this->msg->time, 'config_post_dateformat_hover') ?>">
<?php
$dateTime = CKunenaTimeformat::showDate($this->msg->time, 'config_post_dateformat');
$date = explode(" ", $dateTime);
echo $date[1];
?>
</span>
And just date will be shown.
In the Joomla backend:
Go to the Kunena Configuration page
Go to the "Frontend" tab
There is a parameter called "Message Time Format" which you can set to "hide"
Update:
Having said that, I realised I am using Kunena 2.0.x which you should also do. So I recommend upgrading to the latest version of Kunena, which is still Joomla 1.5 compatible.

Magento Special price validation

Sorry that I'm a total newbie in magento.
I have a multi-vendor magento site where vendors can create product. But when setting product price some users often do some mistakes. Some times special prices are higher than original price. I like to check this mistake. I want a validation script so that when vendors (who have limited admin access) create a new product then they should keep a minimum difference between special price and original price where special price is always lower than original price.
Can any body give some hints?
Thanks
Hope following code will help you
<?php
$product= Mage::getModel('catalog/product')->load(product_id);
$price = $product->getPrice();
$webprice = $product->getwebprice();
$specialprice = $product->getFinalPrice();
if($specialprice==$price)
{?>
<span>$<?php echo number_format($price,2);?></span>
<?php } else if($specialprice<$price) { ?>
<div>
<span>Regular Price:</span>
<span>$ <?php echo number_format($price,2); ?></span>
</div>
<div>
<span>Web Special:</span>
<span>$ <?php echo number_format($specialprice,2); ?> </span>
</div>
<?php } ?>
Even if the user set special prices more than original price,Magento takes cares of it by not displaying that special price .However if you want to do some customization ,the path for price display is :app/design/frontend/default/default/template/catalog/product/price.phtmlIt would be wise if you copy the structure, paste it on your custom theme and continue with your modification.can add your javascript in list.phtml (same product folder).Hope it gives some hint.

Resources