I want to recreate this in magento 2: enter image description here

It's an image slider with attribute icons. I currently have it in magento 1 as a multiple select value: enter image description here

This is the Magento 1 code:

<?php if ($multiSelectArray = $this->getProduct ()->getAttributeText('care_instructions')) : ?>
<div class="main-container col1-layout guides-wrap">
    <div class="main">
        <div class="col-main">
            <div id="care-instructions">
                    if (is_string($multiSelectArray)) {
                        $multiSelectArray = array($multiSelectArray);

                    foreach ($multiSelectArray as $multiSelectItem):

                        $multiSelectItemImage = str_replace(" ", "_", $multiSelectItem);

                        <div class="item"><img src="<?php echo Mage::getBaseUrl('media'); ?>wysiwyg/careinstructions/<?php echo $multiSelectItemImage ?>.jpg" /><span><?php echo $multiSelectItem ?></span></div>
                    <?php endforeach;?>
<?php endif; ?>

How do I assign the images to the attributes? Will the above code work in Magento 2?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.