0

We have a client website which has been built on Magento 1.9 by a third-party. We would like to move the size guide attribute further up the page so it's closer to the size drop down or product description. We've been able to display the attribute label by adding some code to the required product view template but we can't seem to get the size guide text and link appearing.

enter image description here

1
  • Check the code you are calling is correct for attribute value or find some solutions to call the attribute value using attribute identifier. As you are doing fine by adding custom code to call the size guide in the view file. – Amrit Pal Singh May 14 '18 at 12:36
1

You will be using the same code to output your item's attribute-value. Some variations will work, but if your attribute is called size_guide it would generally look like this:

<?php echo $_product->getData('size_guide'); ?>

That said, there are a couple of ways that you can put the code.


Option 1 (quick & dirty): Add the code-snippet to an existing file within your theme's fallback.

copy the contents of app/design/frontend/ultimo/klog/template/catalog/product/view/type/options/configurable.phtml to app/design/frontend/[vendor]/[theme]/template/catalog/product/view/type/options/configurable.phtml

Then just place your snippet at the bottom of the file: <?php echo $_product->getData('size_guide'); ?>

This might require some editing depending on what the actual data is for your attribute


Option 2 (longer, but cleaner): Add the code-snippet to a new block added through layout XML.

In app/design/frontend/[vendor]/[theme]/layout/local.xml add the following snippet:

<catalog_product_view>
    <reference name="product.info.options.wrapper">
        <block type"catalog/product_view" template="path/to/your/template.phtml" name="sizeguide" />
    </reference>
</catalog_product_view>

Then in app/design/frontend/[vendor]/[theme]/template/path/to/your/template.phtml place the following snippet:

<?php $_product = $this->getProduct(); ?>
<?php echo $_product->getData('size_guide'); ?>

Again, you might need to do some editing depending on what the actual data is for your attribute and how you want to present it.

1

I've tried using

<?php echo $_product->getData('size_guide'); ?>

but it outputs the attribute label and ID. Not the actual data. Which should be a string of text which is a hyperlink to the size guide modal window.

The theme has no layout.xml file. So whoever made the theme has modified it using other methods.


Ok, so i used <?php echo $product->getAttributeText('attr_id') ?>

where attr_id is the 'size_guide' and it's now working perfectly fine.

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.