magento set Switch Currency Url - magento

I have problem with Currency URL.
Suppose my URL is www.example.com/by_women/?color=black
Now i want to redirect same page after change currency.
Here is my code.
<?php if($this->getCurrencyCount() > 1): ?>
<span>Select Currency:</span>
<select name="custom-currency-selector" id="custom-currency-selector">
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
<option value="<?php echo $this->getSwitchCurrencyUrl($_code)?>"
<?php if($_code == $this->getCurrentCurrencyCode()): ?>
selected="SELECTED"
<?php endif; ?>>
<?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
<?php endif;

Related

How to make dropdown layered navigation in Magento 2

I'm figuring out about Magento 2 layered navigation. I want to make this navigation with dropdown lists.
I try this code:
<select onchange="setLocation(this.value)">
<option value=""><?php echo 'Choose an Option...' ?></option>
<?php foreach ($this->getItems() as $_item): ?>
<option
<?php if ($_item->getCount() > 0): ?>
value="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?>
<?php else: echo '>' . $_item->getLabel() ?>
<?php endif; ?>
(<?php echo $_item->getCount() ?>)
</option>
<?php endforeach ?>
</select>
but I am getting the error "setLocation(this.value) is not defined". If anyone has another option, please let me know.
Please add below js code:
function setLocation(value) {
window.location = value;
}

How to add currency symbols into the currency list?

How can I add currency symbols into the currency list?
This is the code,
<?php if($this->getCurrencyCount() > 1): ?>
<div class="form-micro">
<select onchange="window.location.href=this.value" name="custom-currency-selector" id="custom-currency-selector">
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
<option value="<?php echo $this->getSwitchCurrencyUrl($_code)?>"
<?php if($_code == $this->getCurrentCurrencyCode()): ?>
selected="SELECTED"
<?php endif; ?>>
<?php echo $_name ?>
</option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
will output,
<option ...>Euro</option>
<option ...>British Pound</option>
<option ...>Danish Krone</option>
<option ...>Swedish Krona</option>
<option ...>Swiss Franc</option>
<option ...>United States Dollars</option>
But I need to add their symbols after the text,
<option ...>Euro €</option>
<option ...>British Pound £</option>
<option ...>Danish Krone DKK</option>
<option ...>Swedish Krona SEK</option>
<option ...>Swiss Franc CHF</option>
<option ...>United States Dollars $</option>
Is it possible?
Yes,Tealou ,it is possible ,you can get this using below code
Mage::app()->getLocale()->currency($cuurencycode)->getSymbol();
Your modified code is
<?php if($this->getCurrencyCount() > 1): ?>
<div class="form-micro">
<select onchange="window.location.href=this.value" name="custom-currency-selector" id="custom-currency-selector">
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
<option value="<?php echo $this->getSwitchCurrencyUrl($_code)?>"
<?php if($_code == $this->getCurrentCurrencyCode()): ?>
selected="SELECTED"
<?php endif; ?>>
<?php echo $_name ?><?php Mage::app()->getLocale()->currency($_code)->getSymbol(); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>

magento mobileshoppe theme - Fatal error: Call to a member function getSize() on a non-object in

I am using mobileshoppe magento theme for our store, when i installed magento it was showing latest products on home page using the code below.
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
Then we customized the theme and it stopped to display latest products on home page even the code above is as it is in admin.
It shows the error -
Fatal error: Call to a member function getSize() on a non-object in D:\wamp\www\magento\app\design\frontend\default\mobileshoppe\template\catalog\product\list\toolbar_top.phtml on line 34
toolbar_top.phtml
<?php if($this->getCollection()->getSize()): ?>
<div class="toolbar">
<?php if( $this->isExpanded() ): ?>
<div class="sorter">
<?php if( $this->isEnabledViewSwitcher() ): ?>
<p class="view-mode">
<?php $_modes = $this->getModes(); ?>
<?php if($_modes && count($_modes)>1): ?>
<label><?php echo $this->__('View as') ?>:</label>
<?php foreach ($this->getModes() as $_code=>$_label): ?>
<?php if($this->isModeActive($_code)): ?>
<strong title="<?php echo $_label ?>" class="<?php echo strtolower($_code); ?>"><?php echo $_label ?></strong>
<?php else: ?>
<?php echo $_label ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</p>
<?php endif; ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
<?php echo $_limit ?>
</option>
<?php endforeach; ?>
</select> <?php echo $this->__('per page') ?>
</div>
<div class="sort-by">
<label><?php echo $this->__('Sort By') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select>
<?php if($this->getCurrentDirection() == 'desc'): ?>
<img src="<?php echo $this->getSkinUrl('images/i_desc_arrow.gif') ?>" alt="<?php echo $this->__('Set Ascending Direction') ?>" class="v-middle" />
<?php else: ?>
<img src="<?php echo $this->getSkinUrl('images/i_asc_arrow.gif') ?>" alt="<?php echo $this->__('Set Descending Direction') ?>" class="v-middle" />
<?php endif; ?>
</div>
</div>
<?php endif; ?>
can anyone please help me on this? Thanks...
Hello Guys I had the same issue on my Mobileshoppe Template. I tried to add products of a category and it didn't work for me.
In the end the solution was to use as mentioned on the official Mobileshoppe page "readme" file: http://magresponsive.devdemoz.com/readme.html
I used the code where it says: 2) Create cms page (home page) step bellow.
Hope it helps somebody.

Magento Set Multiple Currencies

I have a problem with Magento currency: My code is working fine otherwise, now I want to redirect the page after a change of currency.
Suppose my current URL is http://www.example.com/women/?color=black.
Now, When I change currency it will redirect to: http://www.example.com/women/; so it removes ?color=black.
Code:
if($this->getCurrencyCount()>1): ?>
<div class="block block-currency">
<div class="block-title">
<strong><span><?php echo $this->__('Select Your Currency') ?></span></strong>
</div>
<div class="block-content">
<select name="currency" title="<?php echo $this->__('Select Your Currency') ?>" onchange="setLocation(this.value)">
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
<option value="<?php echo $this->getSwitchCurrencyUrl($_code) ?>"<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected="selected"<?php endif; ?>>
<?php echo $_name ?> - <?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php endif;
Updated Code:
<?PHP $currentParams = $this->getRequest()->getParams(); ?>
<div style="float:left; margin-top:10px; color:#727478;">
<!--Change 1 to 0 if you wish to output selector always-->
<?php if($this->getCurrencyCount() > 1): ?>
<span>Select Currency:</span>
<select name="custom-currency-selector" id="custom-currency-selector">
<?php foreach ($this->getCurrencies() as $_code => $_name):
$currencyUrl = $this->getSwitchCurrencyUrl($_code);
foreach ($currentParams as $_param) {
$currencyUrl = $this->helper('core/url')->addRequestParam($currencyUrl, $_param);
}
?>
<option value="<?php echo $currencyUrl; ?>"
<?php if($_code == $this->getCurrentCurrencyCode()): ?>
selected="SELECTED"
<?php endif; ?>>
<?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
<?php endif;?>
Updated Code:
<!--Change 1 to 0 if you wish to output selector always-->
<?php if($this->getCurrencyCount() > 1):
$currentParams = $this->getRequest()->getParams();
?>
<span>Select Currency:</span>
<select name="custom-currency-selector" id="custom-currency-selector">
<?php foreach ($this->getCurrencies() as $_code => $_name):
$currencyUrl = $this->helper('core/url')->addRequestParam($this->getSwitchCurrencyUrl($_code),$currentParams)
?>
<option value="<?php echo $currencyUrl ?>"
<?php if($_code == $this->getCurrentCurrencyCode()): ?>
selected="SELECTED"
<?php endif; ?>>
<?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
<?php endif; ?>
You should add these params to the new url:
$currentParams = $this->getRequest()->getParams();
$currencyUrl = $this->helper('core/url')->addRequestParam(
$this->getSwitchCurrencyUrl($_code),
$currentParams
)
Then use $currencyUrl as url for redirect.

Replace default "Choose an Option" text in Magento layered navigation dropdown

I am using dropdowns to display my layered navigation attribute values. I have 3 filters - price, size and color.
This is what I am trying to do:
1. Get dropdowns for the layered navigation filters.
2. Get the attribute label/name to show up as the first option. Currently, my code puts a default "Choose an Option" value for each dropdown, which I would like to replace with something like "Choose Price", "Choose Size" and "Choose Color".
Here is my current code for template/catalog/layer/filter.phtml. The dropdown works, but I am stuck at getting the attribute label instead of "Choose an Option"
<select onchange="setLocation(this.value)">
<option value='' disabled selected style='display:none;'>Choose an Option</option>
</option>
<?php foreach ($this->getItems() as $_item): ?>
<option
<?php if ($_item->getCount() > 0): ?>
value="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?>
<?php else: echo '>' . $_item->getLabel() ?>
<?php endif; ?>
(<?php echo $_item->getCount() ?>)
</option>
Try this code. It is tested in all the browsers.
<select onchange="setLocation(this.value)">
<?php $count = 0; ?>
<?php foreach ($this->getItems() as $_item): ?>
<?php $count++; ?>
<?php if($count == 1): ?>
<option value='' disabled selected style='display:none;'>Choose <?php echo $attribute_code = $_item->getFilter()->getName();?> </option>
<?php endif; ?>
<option <?php if ($_item->getCount() > 0): ?> value="<?php echo $this->urlEscape($_item->getUrl()) ?>">
<?php echo $_item->getLabel() ?> <?php else: echo '>' . $_item->getLabel() ?> <?php endif; ?> (<?php echo $_item->getCount() ?>) </option>
<?php endforeach; ?>
</select>

Resources