Set currency name in magento - magento

I have a store localized in Romania.
Recently I noticed that most online from Romania have currency as Leu/Lei instead of RON.
I was trying to change that too but probably I'm missing something.
in \magento\lib\Zend\Locale\Data\root.xml it's set like this:
<currency type="RON">
<symbol>RON</symbol>
</currency>
and ro.xml (same path) have:
<currency type="RON">
<displayName>leu</displayName>
<displayName count="one">leu</displayName>
<displayName count="few">lei</displayName>
<displayName count="other">lei</displayName>
</currency>
I didn't see any other place where currency is set.
Any clues?

Related

How can I show custom attribute value as menu item label in magento 2?

I have created a custom attribute for menu title on category add/edit page in my magento 2 setup. I want to show the value of the attribute saved in database instead of the category title on main menu. How can I do this. Please help
I was searching online and didn't find any exact solution to my problem.
You need to code in the frontend theme and also in your module to display your display custom attribute on the placement of the category title.
Custom/Module/view/frontend/layout/catalog_category_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="category.view.container">
<block class="Magento\Catalog\Block\Category\View" name="category.heading" template="Example_CategoryHeading::category/heading.phtml" before="category.description"/>
</referenceContainer>
<referenceBlock name="page.main.title" remove="true"/>
</body>
</page>
Turn on the Template path hints and find the phtml file, where you can find the file location attribute to display in the menu title. Remember to override your custom theme or module.
For Template path hints:
On the Admin sidebar, go to Stores > Settings > Configuration.
In the left panel, expand Advanced and choose Developer.
Expand Expansion selector in the Debug section and do the following:
To get the category attribute:
$categoryId = 3;
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $_objectManager->create('Magento\Catalog\Model\Category')->load($categoryId);
echo $category->getName();
echo $category->getData('<attribute_code>');
Remember, object manager is not recommended.
In the app/design/frontend/theme vendor/themename/Magento_Catalog/layout/ folder, the file catalog_category_view.xml is responsible for displaying the title. In this xml file, the setPageTitle action method is used, and you can override the category default title according to your requirement.

How can I find (and rehabilitate, if necessary) the Code Snippet I created?

I created a code snippet (the first of many, hopefully) using mainly this article as guidance.
It seemed to work. Here are the steps I took:
First, I created this file with the code snippet (HtmlTableRowWithTwoCells.snippet):
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/CodeSnippet">
<CodeSnippet Format="1.0.0">
<!-- The Title of the snippet, this will be shown in the snippets manager. -->
<Title>Create a 2-Cell HTML Table Row</Title>
<!-- The description of the snippet. -->
<Description>Creates a 2-Cell Row to be added to an HtmlTable</Description>
<!-- The author of the snippet. -->
<Author>Warble P. McGorkle for Platypi R Us (Duckbills Unlimited)</Author>
<!-- The set of characters that must be keyed in to insert the snippet. -->
<Shortcut>row2</Shortcut>
<!-- The set of snippet types we're dealing with - either Expansion or -->
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<!-- Now we have the snippet itself. -->
<Snippet>
<Declarations>
<Literal>
<ID>RowName</ID>
<ToolTip>Enter the Row instance name</ToolTip>
<Default>RowName</Default>
</Literal>
<Literal>
<ID>Cell1Name</ID>
<ToolTip>Enter the name for Cell 1</ToolTip>
<Default>Cell1Name</Default>
</Literal>
<Literal>
<ID>Cell2Name</ID>
<ToolTip>Enter the name for Cell 2</ToolTip>
<Default>Cell2Name</Default>
</Literal>
</Declarations>
<!-- Sepecify the code language and the actual snippet content. -->
<Code Language="CSharp" Kind="any">
<![CDATA[
var $RowName$ = new HtmlTableRow();
var $Cell1Name$ = new HtmlTableCell();
var $Cell2Name$ = new HtmlTableCell();
$RowName$.Cells.Add($Cell1Name$);
$RowName$.Cells.Add($Cell2Name$);
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Then, I created this "manifest" file (.vscontent):
<?xml version="1.0" encoding="utf-8" ?>
<VSContent xmlns="http://schemas.microsoft.com/developer/vscontent/2005" >
<Content>
<FileName>HtmlTableRowWithTwoCells.snippet</FileName>
<DisplayName>Inserts a 2-Cell HTML Table Row</DisplayName>
<Description>Inserts a 2-Cell Row to be added to an HtmlTable</Description>
<FileContentType>Code Snippet</FileContentType>
<ContentVersion>2.0</ContentVersion>
<Attributes>
<Attribute name="lang" value="csharp"/>
</Attributes>
</Content>
</VSContent>
I zipped those two files together, renamed the extension from .zip to .vsi, 2-clicked it, and installed it into the "My Code Snippets" folder here with these steps:
And it indicates the snippet was installed in a reasonable location:
Yet, when I attempt to add a Code Snippet in VS, the only categories I see are these (no "My Code Snippets"):
When I select Tools > Code Snippets Manager..., I can navigate to Visual C# > My Code Snippets, but it is empty.
When I use the Code Snippets Manager's "Import" button and navigate to the location of the snippet and attempt to add the snippet file, I get, "The snippet files chosen were not valid."
Why does it tell me it installed successfully, when it apparently didn't (or where is it hiding)? What flaming hoop did I neglect to catapult myself through?
Is the "weird" name of the "manifest" file possibly the problem? ".vscontent" seems odd to me, but that's what the article referenced above says to name it. Perhaps that was just on oversight, and it should really be [snippetName].vscontent?
UPDATE
Apparently, naming the "manifest" file *.vscontent" is not the problem. Maybe it's a problem, but it's not the problem, because I named it the same as the .snippets file (except for the extension), went through the installation process again, and got the same exact results: seeming success, actual demoralization.
BTW, by default, when choosing a category into which to place the snippet, the Code Snipeets Manager puts a checkbox in "Microsoft Visual Studio Tools for Applications 2005 > My Code Snippets". I had previously unticked that and ticked the topmost "My Code Snippets"; this time I retained the default selection, PLUS my preferred location/category PLUS "Visual C#"
But alas and anon, the only category of those that seems to dispaly via Ctrl+K, X in VS is C#, and the expected shortcut ("row2") does not appear in the snippet dropdown.
Here's an easier way (and, as a bonus, it works):
Download the Snippets Designer:
Write the code directly in Visual Studio:
var RowName = new HtmlTableRow();
var Cell1Name = new HtmlTableCell();
var Cell2Name = new HtmlTableCell();
RowName.Cells.Add(Cell1Name);
RowName.Cells.Add(Cell2Name);
Right-click and select "Export as Snippet"
This puts the code in the Snippet Designer. Here's what it looks like after setting a few properties, and electing which parts of the code would be replaceable:
This is quite easy - sure beats the "olde-fashioned" way I was trying (which would have been okay, had it worked).
All I had to do was right-click the elements of code I wanted to replace on adding a new snippet, set the snippet's shortcut and description properties in Solution Explorer, save it, and voila!
Now mashing Ctrl+K, X in VS shows the snippet in "My Code Snippets" along with its description and shortcut:
Selecting it adds the snippet with the replacement strings highlighted:

Magento custom shipping module translations

I created a custom shipping module which is working.
I want to set the 2 texts displayed on the checkout page to come from a translation file.
config.xml
<default>
<carriers>
<starmall>
<active>1</active>
<model>Starmall_Shippingcost_Model_Carrier_Starmall</model>
<title>Carrier Title</title>
<name>Method Name</name>
<price>0.00</price>
<specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
</starmall>
</carriers>
</default>
Admin screen:
Checkout frontend screen:
QUESTION: I want to set the "aaa" and "bbb" texts in code to come from a translation file.
I can set the "aaa" text in code using
$method->setMethodTitle(Mage::helper("starmall_config")->__("Starmall_shipping_method_title"));
Which then displays this:
How can I set the "bbb" text in code?
The following does not work:
$method->setCarrierTitle("xxxxxx");
$method->setTitle("xxxxx");
Yes use translation function !
$method->setCarrierTitle( Mage::helper('core')->__('string1') );
$method->setTitle(Mage::helper('core')->__('string2'));
Then add this string to your translation CSV file !

palettes of icons in Google Earth (Mac)

(Cross posted from the GE support groups - now defunct?)
Having trouble using the gs:x extensions to use palettes of icons in an icon
group.
I have loaded the appropriate xmlns:gx="http://www.google.com/kml/ext/2.2"
into the kml header but get the message "Unknown type gs:x
on my Macintosh under GE Google Earth 6.0.3.2197
I suspect this has not been implemented on the Mac version - anybody
with experience on this?
Final code was as follows and it fails on the first gx:s line.
It also fails in the same way if I use the now deprecated x (rather than gx:x)
Also, as shown it follows the kml documentation but I think all terminating terms should be of the form /gx:x rather than gx:x/
as shown in the KML reference. Making that change does not help as it never gets to that point anyway.
The header was copied from a GE placemark copied and pasted into the
editor.
Any help appreciated.
Bob J.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<StyleMap id="s_Ic_SP">
<Pair><key>normal</key><styleUrl>#sn_Ic_SP</styleUrl></Pair>
<Pair><key>highlight</key><styleUrl>#sh_Ic_SP</styleUrl></Pair>
</StyleMap>
<Style id="sn_Ic_SP">
<IconStyle>
<scale>1.8</scale>
<Icon>
<href>Icons/Traps.png</href>
<gx:x>0<gx:x/><gx:y>128<gx:y/> <gx:w>64<gx:w/><gx:h>64<gx:h/>
</Icon>
<hotSpot x="32" y="1" xunits="pixels" yunits="pixels"/>
</IconStyle>
<BalloonStyle>
<displayMode>default</displayMode><bgColor>ff00d0ff</bgColor>
<text><![CDATA[<font face="Comic Sans MS" /><table
bgcolor="#ff8000" cellspacing="3" width="160">
<tr bgcolor="#ffff80"><td><b>Sponsor $[name]</b><br/><br/>$
[description]</td></tr></table>]]></text>
</BalloonStyle>
<LabelStyle>
<scale>0.9</scale><color>ff00ffff</color>
</LabelStyle>
<LineStyle><color>ff00ffff</color><width>2.0</width></LineStyle>
<ListStyle>
<ItemIcon>
<href>Icons/Traps.png</href>
<gx:x>0<gx:x/><gx:y>128<gx:y/> <gx:w>64<gx:w/><gx:h>64<gx:h/>
</ItemIcon>
</ListStyle>
</Style>
etc.
Oooops
Seems my problem was a syntax problem
The gx:x set do work correctly. However, they are not operational inside the ItemIcon group as shown in my example. In fact they are ignored in that group.
Thanks for your tolerance of my stupidity
Bob J.

collective.xdv and multiple theme files

I am having different theme HTML files for different site sections. There are some major layout differences depending if the page is the front page, or a certain subsection.
As far as I see the default behavior is just to have one HTML file:
http://pypi.python.org/pypi/collective.xdv#usage
What would be the best strategy to use multiple theme files, slight rule variations and collective.xdv?
Plone 4.1b.
We usually just utilize plain xdv and use the rules.xml (or whatever you want to call it) file to setup the theme templates leaving the corresponding properties in the collective.xdv controlpanel empty. Nesting rules gives you quite some fexibility when asigning different templates:
<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://namespaces.plone.org/xdv"
xmlns:css="http://namespaces.plone.org/xdv+css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<theme css:if-content="body.section-front-page" href="frontpage.html" />
<theme css:if-path="/section/subsection/somefolder" href="somefolder.html" />
...
<rules css:if-content="#visual-portal-wrapper">
<!-- The default theme -->
<theme href="theme.html" />
<rules css:if-content="body.section-somefolder">
<!-- Secific rules for somefolder go here -->
...
</rules>
</rules>
You should use the Alternate Themes settings to define alternative layouts when the url matches a specific regular expression.
For example, we have a Plone site named "Plone" and accessible at url localhost:8080/Plone. To provide a different layout for the Home page, we can define the following in the registry (or TTW in the Plone Control Panel > XDV Settings section):
<record field="alternate_themes" interface="collective.xdv.interfaces.ITransformSettings" name="collective.xdv.interfaces.ITransformSettings.alternate_themes">
<field type="plone.registry.field.List">
<description>Define alternate themes and rules files depending on a given path. Should be of a form 'path theme rules' (or 'path rules' with xdv 0.4), where path may use a regular expression syntax, theme is a file path or URL to the theme template and rule is a file path to the rules file.</description>
<required>False</required>
<title>Alternate themes</title>
<value_type type="plone.registry.field.TextLine">
<title>Theme</title>
</value_type>
</field>
<value>
<element>^.*/Plone(/)?$ python://my.xdvtheme/templates/alternative/index.html python://my.xdvtheme/rules/alternative/index-rules.xml</element>
</value>
</record>
This way, the home page will use the alternative layout, while all the other pages will use the main layout specified in Theme template and Rules template
You can provide multiple definitions according to the different sections of your site.
My personal Plone site uses different theme and rules files for different parts.
Are you using the XDV control panel at /##xdv-settings?
In the Theme template and Rules File fields I put my default (i.e most used) files.
In the Alternate Themes textbox you can then provide alternate theme and rules files depending on a given path.
The format is path theme rules.
Here are some examples from my website's config:
.*/login_form|.*logged_out
/home/zope/production/theme/theme.html
/home/zope/production/theme/login.xml
/media/blog$
/home/zope/production/theme/blog.html
/home/zope/production/theme/blog.xml
/media/software
/home/zope/production/theme/software.html
/home/zope/production/theme/media.xml
As you can see, you can use regular expression syntax to match the paths.
The first line is for styling the login and logout pages.
The second for styling only my blog's landing page (henche the $)
the third styles my software page.
Works like a charm.

Resources