0

On the category page I have an attribute showing values, that attribute can have multiple values and will show all the values separated by commas. Is there a way to get the highest value from the attribute and also the lowest?

What is have to display the values:

<?php if ($_product->getResource()->getAttribute('scherm_breedte')->getFrontend()->getValue($_product)): ?>
    <strong>Breedte</strong>: <?php echo $_product->getResource()->getAttribute('scherm_breedte')->getFrontend()->getValue($_product); ?>
<?php endif; ?>
  • Which type does the attribute have? – Akif Aug 11 '16 at 11:14
  • which type of values it have like integer or something else can please show example of your values – Ashish Madankar M2 Professiona Aug 11 '16 at 11:16
  • The type is: Multiple selection and the input will be numbers like: 150 160 200 210 250 300 – n00bly Aug 11 '16 at 11:17
1

Basically its not a Magento question rather a PHP question.

Try like this

$attribtesData = $_product->getResource()->getAttribute('scherm_breedte')->getFrontend()->getValue($_product);
    $attributeDataArray = explode(",",$attribtesData);

    echo 'Max attribute Value = '.max($attributeDataArray);
    echo 'Min attribute Value = '.min($attributeDataArray);

Hope this helps you.

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.