New OpenCart user, testing with a clean install of 1.5.2.1.
I would like to be able to add multiple custom product attributes or data fields that are only visible when viewing a product via the admin interface and NOT displayed in the public storefront.
Usage scenario: Store owner is using OpenCart as a catalog for products with negotiable prices and not actually selling products through the cart. A customer calls and asks for a price on product x. Store owner would like to be able to pull up the product in the admin interface and and look at certain fields that contain non-public info. Examples of such fields might be desired sales price to an end user, a separate price for a reseller and the store owner's actual original cost for the product.
What would be a sensible way to enable this kind of functionality in the admin area?
Adding a new "attribute" seems to be the method for adding non-default fields to a product but any added attribute is automatically displayed in the public storefront as there is no "disable/enable" option for individual attributes. I also tried setting sort order to something like -1 but this doesn't prevent the attribute from being displayed.
I'm not sure if using attributes in this manner and then attempting to hide them is a reasonable approach, if there is an easier or more appropriate way in OpenCart's default functionality or if it will require custom coding to permit non-public fields to be stored in the database and viewed only in the admin section for a given product.
Easy solution is to use the location field as it is not used on the front-end and can store 128 characters
Location value: Cost $x.xx Reseller Lowest $x.xx Desired $x.xx
Location value: Cost $x.xx Reseller Lowest $x.xx Desired $x.xx
Hi! I am also interested in having a good solution for hidden attributes (that is, product attributes for admin purpose that are not shown in the front store, eg. cost value).
Any alternative to use the Location field?
Thanks in advance :-)
E
Any alternative to use the Location field?
Thanks in advance :-)
E
For anyone still interested, a quick solution I have been using is to create an attribute group named "Hidden" for any attributes I do not wish to display on the front end. A quick check in product.tpl and compare.tpl then lets me filter this group out of the render.
product.tpl
compare.tpl
This solution may not be ideal in all circumstances, but it is extremely simple to implement and serves it purpose.
product.tpl
Code: Select all
<div id="tab-attribute" class="tab-content">
<table class="attribute">
<?php foreach ($attribute_groups as $attribute_group) { ?>
<?php if ($attribute_group['name'] != "Hidden") { ?>
<thead>
<tr>
<td colspan="2"><?php echo $attribute_group['name']; ?></td>
</tr>
</thead>
<tbody>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<tr>
<td><?php echo $attribute['name']; ?></td>
<td><?php echo $attribute['text']; ?></td>
</tr>
<?php } ?>
</tbody>
<?php } ?>
<?php } ?>
</table>
</div>
Code: Select all
<?php foreach ($attribute_groups as $attribute_group) { ?>
<?php if ($attribute_group['name'] != "Hidden") { ?>
<thead>
<tr>
<td class="compare-attribute" colspan="<?php echo count($products) + 1; ?>"><?php echo $attribute_group['name']; ?></td>
</tr>
</thead>
<?php foreach ($attribute_group['attribute'] as $key => $attribute) { ?>
<tbody>
<tr>
<td><?php echo $attribute['name']; ?></td>
<?php foreach ($products as $product) { ?>
<?php if (isset($products[$product['product_id']]['attribute'][$key])) { ?>
<td><?php echo $products[$product['product_id']]['attribute'][$key]; ?></td>
<?php } else { ?>
<td></td>
<?php } ?>
<?php } ?>
</tr>
</tbody>
<?php } ?>
<?php } ?>
<?php } ?>
I tried this little patch.
It has the intended effect that you can hide attributes from showing up in the front end.
But it also has a nasty side-effect: in the front-end, the user now sees an extra tab in the Product Details Page that is empty.
That's caused by the suprression of attributes belonging to attribute_group "Hidden".
--skidrow
It has the intended effect that you can hide attributes from showing up in the front end.
But it also has a nasty side-effect: in the front-end, the user now sees an extra tab in the Product Details Page that is empty.
That's caused by the suprression of attributes belonging to attribute_group "Hidden".
--skidrow
Even better than editing the template, you can filter the attribute groups in the controller.
The attached vqmod updates both the product and compare and avoids the extra tab showing up when there are no visible attributes. It will hide any attribute group that starts with *
The attached vqmod updates both the product and compare and avoids the extra tab showing up when there are no visible attributes. It will hide any attribute group that starts with *
Great mod, tarheit, thanks!tarheit wrote:It will hide any attribute group that starts with *
I'm using yours, but added a new new property, "hidden_attribute_groups", to capture those hidden groups and have them available on the product.tpl page.
Code: Select all
$attribute_groups = $this->data['attribute_groups'];
$this->data['hidden_attribute_groups'] = array();
foreach($attribute_groups as $key=>$group){
if(strpos($group['name'], '*') === 0){
$this->data['hidden_attribute_groups'][] = $attribute_groups[$key];
unset($attribute_groups[$key]);
}
}
$this->data['attribute_groups'] = $attribute_groups;
EDIT: Ignore me, I added the asterix to the attribute title and not the attribute GROUP title
I installed your XML file but it doesn't seem to work at all, am I missing something?
I need the colour attribute for my category page filter to work but I don't want it displayed on the product page because it could be confusing for customers (I bundle all variations of a colour together such as 'burgundy', 'wine' and 'red' as 'red' for example but the product description will say the actual colour).
I'm running 1.5.6.4, is it compatible?
Thnaks,
Ty
Hi Tarheit,tarheit wrote:It will hide any attribute group that starts with *
I installed your XML file but it doesn't seem to work at all, am I missing something?
I need the colour attribute for my category page filter to work but I don't want it displayed on the product page because it could be confusing for customers (I bundle all variations of a colour together such as 'burgundy', 'wine' and 'red' as 'red' for example but the product description will say the actual colour).
I'm running 1.5.6.4, is it compatible?
Thnaks,
Ty
Who is online
Users browsing this forum: ianhaney50, paulfeakins and 61 guests