2

I have a question regarding an attribute I have to set up in Magento.

Here I have the following values:

0-1000
1000-2000
2000-3000
3000-4000
4000-5000
5000-6000
6000-8000
8000-10000
>10.000

If I have a product with value 900 the layered navigation should add this to the top value-range.

0-1000 (1)
1000-2000
2000-3000
3000-4000
4000-5000
5000-6000
6000-8000
8000-10000
>10.000

If I have another product with value 2350 it should be added with (1) to the third line.

0-1000 (1)
1000-2000
2000-3000 (1)
3000-4000
4000-5000
5000-6000
6000-8000
8000-10000
>10.000

And so on.

After much reading and digging I found out I need an integer/decimal attribute (without the currency sign).

As a test I've setup a price attribute and this works, however I see the currency sign.

I followed this link and the answer from Floordesign. I'm using the euro currency and not the Romanian currency so "RON" doesn't work for me.

Is there someone who can help me out with this one?

2

If you want to remove the current shop's currency symbol from any text you can get the currency code of the current shop. From this you can get the symbol then simply perform a simple str_replace

$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
$current_currency_symbol = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
$text_with_symbol = '0,00 € - 99,99€';
$text_without_symbol = str_replace($current_currency_symbol, '', $text_with_symbol);
echo $text_without_symbol;

You could easily create a helper and add this as a removeCurreny function and so you can call it in classes or templates easily.

| improve this answer | |
0

I've stumbeled across the same problem.

In my case it is an attribute representing years. Since I don't know what currencys the customer will use I needed a universal solution and came up with something. You have to modify two files. One is for displaying the filter itself (first), the other is for displaying selected filters (second). My attribute has the code 'year' and is of type 'Price'.

first: app/design/frontend//default/template/catalog/layer/filter.phtml

$tempLabel = $_item->label;
if ($this->_alias == "year_filter") :
    $tempLabel = substr ( $tempLabel, 0, strrpos ( $tempLabel, "," ) ); // cut decimal and currency at the end
    $tempLabel2 = substr ( $tempLabel, 0, strpos ( $tempLabel, "," ) ); // get first value without currency
    $tempLabel3 = substr ( $tempLabel, strpos ( $tempLabel, "-" ) ); // get second value with seperator
    $tempLabel = $tempLabel2 . " " . $tempLabel3; // combine the two values
    $tempLabel = str_replace(".", "", $tempLabel); // remove dots from magnitude seperation 
endif;
?>
<div class="left">
    <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $tempLabel ?></a>
</div>

second: app/design/frontend//default/template/catalog/layer/state.phtml

<?php
$tempLabel = $_filter->getLabel();
if ($_filter->getFilter()->getRequestVar() == "year") :
    $tempLabel = substr ( $tempLabel, 0, strrpos ( $tempLabel, "," ) ); // cut decimal and currency at the end
    $tempLabel2 = substr ( $tempLabel, 0, strpos ( $tempLabel, "," ) ); // get first value without currency
    $tempLabel3 = substr ( $tempLabel, strpos ( $tempLabel, "-" ) ); // get second value with seperator
    $tempLabel = $tempLabel2 . " " . $tempLabel3; // combine the two values
    $tempLabel = str_replace(".", "", $tempLabel); // remove dots from magnitude 
endif;
?>
<span class="label"><?php echo $this->__($_filter->getName()) ?>:</span> <?php echo $this->stripTags($tempLabel) ?>

What it does is:

  1. initial label value: 1.000,00 € - 2.000,00 €
  2. cut decimal and currency at the end
    • temp = 1.000,00 € - 2.000
  3. get first value without currency
    • temp2 = 1.000
  4. get second value with seperator
    • temp3 = - 2.000
  5. combine the two values
    • temp = 1.000 - 2.000
  6. remove dots from magnitude seperation
    • temp = 1000 - 2000
  7. set the label

Hope this helps!

| improve this answer | |

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.