Post by dm_cns » Wed Mar 21, 2012 2:11 am

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.

Newbie

Posts

Joined
Wed Mar 21, 2012 1:40 am

Post by uksitebuilder » Wed Mar 21, 2012 5:21 am

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

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by emilioj » Wed Nov 07, 2012 7:28 pm

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

Newbie

Posts

Joined
Fri Jan 27, 2012 5:21 pm

Post by Soutar » Wed Nov 28, 2012 12:16 am

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

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>
compare.tpl

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 } ?>
This solution may not be ideal in all circumstances, but it is extremely simple to implement and serves it purpose.

Newbie

Posts

Joined
Wed Nov 28, 2012 12:11 am

Post by skidrow » Wed Dec 19, 2012 2:00 am

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

User avatar
Newbie

Posts

Joined
Wed Dec 19, 2012 1:51 am

Post by tarheit » Fri Jan 31, 2014 3:45 am

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 *

New member

Posts

Joined
Wed Jan 22, 2014 5:16 am

Post by Buz » Sat May 10, 2014 1:43 am

tarheit wrote:It will hide any attribute group that starts with *
Great mod, tarheit, thanks!

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;

Buz
Newbie

Posts

Joined
Sat May 10, 2014 1:38 am

Post by deadjoe » Tue Nov 15, 2016 10:37 pm

EDIT: Ignore me, I added the asterix to the attribute title and not the attribute GROUP title ::)
tarheit wrote:It will hide any attribute group that starts with *
Hi Tarheit,
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

Newbie

Posts

Joined
Tue Nov 25, 2014 8:42 pm
Who is online

Users browsing this forum: ianhaney50, paulfeakins and 61 guests