Why use product Attibute?
- Doesn't need to create extra table or column on database.
- Because we only modificate the product.tpl and compare.tpl.
- You will able to put as many "extra fields" as you want + multi-language support.
Step 1. Modificating Product Page
- Admin Page
- Create two Attribute Group (Catalog > Attribute > Attribute Groups)
- Product Info
- Product Details
- Create Attribute inside Attribute Group (Catalog > Attribute > Attributes)
- Product Info : ISBN, Pages, Author and Publisher
- Product Details: Reading Level, Pages, Author, Publisher, ISBN-10, ISBN-13, Book Dimension
- Create Product (ie. Harry Potter)
- Go to Attribute Tab
- On input (attribute column) choose all attribute above.
- For the text column, it's up to you.
- Create two Attribute Group (Catalog > Attribute > Attribute Groups)
- Product Template ( yourtheme/template/product/product.tpl )
- Put code bellow on line 31 (marked start-end)
Code: Select all
<div class="description"> .... <span><?php echo $text_stock; ?></span> <?php echo $stock; ?> <br/><br/> <!-- Start Additional Info --> <?php if ($attribute_groups) { ?> <?php foreach ($attribute_groups as $attribute_group) { ?> <?php if ($attribute_group['name'] == 'Product Info') { ?> <?php foreach ($attribute_group['attribute'] as $attribute) { ?> <span><?php echo $attribute['name']; ?></span> <?php echo html_entity_decode($attribute['text']); ?><br /> <?php } ?> <?php } ?> <?php } ?> <?php } ?> <!-- End Additional Info --> </div>
- Put code bellow on line 31 (marked start-end)
- Open Compare Template ( yourtheme/template/product/compare.tpl )
Put code bellow:Code: Select all
<?php if ($attribute_group['name'] != 'Product Info') { ?> <!-- line 88 --> <?php } ?> <!-- line 108 -->
- You can change attribute group "Product Info" to any word, as long it's consist with $attribute_group['name'] filter.
- It's not just one attribue group, you can filtering two or three attribute group.
- If you put a link <a href=".."></a> or any html code on attribute text, do not forget use html decode.
Code: Select all
<?php echo html_entity_decode($attribute['text']); ?>
- With some modification, you can show certain product attribute on Category Page. As product info or may be product label.
- And FYI, you able to use product attribute as a condition value.
Code: Select all
<?php if ( $attribute['name'] == 'prodLabel' && $attribute['text'] == 'Free Shipping') { echo '<span class="freeShipping">'.$attribute['text'].'</span>'; } ?>
- Like what old man say: The only limitation, is your imagination!
Note:
Since most user unable to reply this post, if you want to suggest think to improve this tutorial you can PM me. No Question Please!
Make new post on Support Forum if you have any question.