I've seen that in OpenCart's PHP code, different aspects of a product are accessed like this:
$product['href']
$product['thumb']
$product['name']
$product['description']
$product['reviews']
$product['price']
etc ..
Suppose that for all the products in my Store, I have an Attribute Group named 'AttGrp', and this Attribute Group contains only 1 attribute named 'Att'. Thus, ALL products in my Store will have a value for the attribute 'Att'. So suppose I want to directly access the value of 'Att' for a given product (e.g. show it as a tooltip, etc ..), how would I do that ?
And in the catalog product page, they can be found in array $attribute_groups.
So, If you just want to see it on your front end product page, I would suggest adding this in catalog/view/theme/default/template/product/product.tpl:
Code: Select all
<?php
if ($attribute_groups) {
foreach ($attribute_groups as $attribute_group) {
if ($attribute_group['name'] != "AttGrp") {
continue;
}
foreach ($attribute_group['attribute'] as $attribute) {
if ($attribute['name'] != "Att") {
continue;
}
$AttValue = $attribute['text'];
}
}
}
?>
Code: Select all
<?php
if (isset($AttValue)) {
echo "Att: " . $AttValue;
}
?>
Regards,
Midgette
I've just used this and it works great. Thanks!
jgsw
Quick Edit Admin Panel (40% off!) - CSS Unique (only $10!)
Sticky Admin Menu (Free) - Add Scripts & Styles to head (Free)
Code: Select all
<?php if ($attribute_groups) { ?>
<div id="tab-bio" class="tab-content" style="display:block">
<table class="attribute">
<?php foreach ($attribute_groups as $attribute_group) { ?>
<?php if ($attribute_group['name'] == 'Sobre el Autor') { ?>
<thead>
<tr>
<td colspan="2"><?php echo $attribute_group['name']; ?></td>
</tr>
</thead>
<tbody>
<tr>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<!-- <tr>
<td><?php echo $attribute['name']; ?></td> -->
<td><?php if ($attribute['name'] != "Fotografía") {
echo nl2br($attribute['text']); } ?><?php if ($attribute['name'] != "Biografía") {
echo htmlspecialchars_decode($attribute['text']); } ?></td>
<!-- </tr> -->
<?php } ?>
</tr>
</tbody>
<?php } ?>
<?php } ?>
</table>
</div>
<?php } ?>
May you please give a hand?
Thanks
Pedro Martin - websitesbuilder.com.au
Checkout my free extensions: https://www.opencart.com/index.php?rout ... r=comprido
Code: Select all
<?php if ($attribute_groups) { ?>
<div id="tab-bio" class="tab-content" style="display:block">
<table class="attribute">
<?php foreach ($attribute_groups as $attribute_group) { ?>
<?php if ($attribute_group['name'] == 'About the Author') { ?>
<thead>
<?php foreach ($attribute_group['attribute'] as $attribute) {
if($attribute['name']=="Photo") {
?>
<tr>
<td colspan="2"><?php echo $attribute_group['name']; ?></td>
</tr>
<tr>
<td><?php echo "<img src='image/data/autores/".$attribute['text'].".jpg' style='max-width:200px;max-height:200px'; "; ?></td>
<?php } } ?>
<?php foreach ($attribute_group['attribute'] as $attribute) {
if($attribute['name']=="Biography") {
?>
<td><?php echo htmlspecialchars_decode($attribute['text']); ?></td>
<?php } } ?>
</tr>
</tbody>
<?php } ?>
<?php } ?>
</table>
</div>
<?php } ?>
Attachments
Retrieve custom atributtes for opencart products. Show author photo in opencart tabs. - custom_attributes.png (204.35 KiB) Viewed 3731 times
Pedro Martin - websitesbuilder.com.au
Checkout my free extensions: https://www.opencart.com/index.php?rout ... r=comprido
Big Decision
Website Production, Ecommerce & Digital Marketing in the UK
http://www.bigdecision.co.uk
Users browsing this forum: No registered users and 16 guests