It would be awesome if product attributes could be individually exposed to Views.

Although the potential to leave out attributes by accident is possible, this would significantly improve the ability to create a step-by-step product configuration process and add the final result to our cart with little to no store modification.

In doing this, it may be necessary to add a customizable "Next Step" button; like the "Buy it now" button already available to Views.

Anyone else that's interested in this, I'd like to see your feedback as well.

Comments

devkinetic’s picture

I second this, disappointed that I can't create views that lists a nodes attributes

wjaspers’s picture

Whoops, I guess I didn't look close enough at other modules available.
To all interested, we may want to try out Ubercart Views.
There's a sub-module which provides some of this functionality.

EDIT: It looks like the module stated above provides access to these things in "Views"; however, the "Attributes" access is more-or-less the output of a configuration for a particular product. This module doesn't appear to provide the ability to selectively display product's attributes during the "add to cart" process.

TR’s picture

Version:6.x-2.3» 7.x-3.x-dev
Issue tags:-views, -product attributes

This should be implemented in 7.x-3.x first.

GHapsis’s picture

Any news about this?

benitezv1ang’s picture

how are we doing with this Issue

DanZ’s picture

It appears that nobody is working on this. While this sounds like a great idea, I know that I have too many other projects that are higher priority. I expect that the other contributors are in the same situation.

In other words, if you want this to get done any time soon, the best thing to do is to write a patch yourself, or hire someone to do it. You will get support here if you do that. If you want to hire someone, see https://drupal.org/paid-services, https://drupal.org/drupal-services, and http://www.ubercart.org/forum/bounties for starters.

The first thing to do is to specify exactly where these will show up. Cart products, maybe? Start by describing exactly what a view using this stuff would look like and how it would be used.

jhenson’s picture

I think this would be great as well, but I think for different reasons. For my clients, they want to be able to allow their customers to filter the products on a view based on the attributes the products have. My immediate need is a jewelry store that would like customers to be able to view all rings of a certain size. The sizes are attributes, but I don't see any ability to create Views Filters based on attributes (unless I'm missing something :) I can also see this being extremely important for clothing stores (show me all Large T-Shirts), housewares (show me all green flatware), etc.

I understand this can also be accomplished with taxonomies, but that requires double data entry and management if you want to use the attributes sku# and stock handling. I'm currently looking into how to create custom views filters but must admit its a bit above my pay grade. I'm reviewing the views documentation, but if anyone knows a great tutorial on getting started please message me.

Triskelion’s picture

I just started looking at the underlying tables with the intent of creating uc_attributes.views.inc. I found the roadblock.

Attributes will never be meaningfully exposed until the table uc_product_adjustments is upgraded. It presently records the product nid, and the adjusted SKU (model) along with an array of key:value pairs of the form Attribute ID => Option ID.

To expose this information to Views, this table will have to be changed to four fields (nid,aid,oid,model), so relationships can be established with uc_product_attributes and uc_product_options. Once this is done, exposing the attributes will be trivial.

Hopefully one of the maintainers who is familiar with uc_attributes can get back to this thread with some suggestions on how to proceed.

longwave’s picture

mattbk’s picture

Just wanted to add my support to this feature request. @Triskelion, if I knew how to start with that, I would :-(

hom3chuk’s picture

Doubling #7 and subscribing. This feature is a must.

acdtrp’s picture

Subscribing. Really need this feature.

mattbk’s picture

An additional reason for this is that I could then have a single SKU for a race registration (and therefore be able to use the stock module) but still split up the roster page according to division or other attributes.

Problue Solutions’s picture

also need this to use in conjunction with views data export to export attributes to a csv file

mattbk’s picture

Could the values in https://drupal.org/project/uc_who_bought_what be exposed to Views as a workaround?

varsharani’s picture

Thanks! But That is not compatible with drupal7 version.
I have four different size attributes and assigned different prices. how can view in only view instead of add to cart form. and it redirect to product page in drupal7.

sin’s picture

Issue summary:View changes
Status:Active» Needs review
StatusFileSize
new3.76 KB
PASSED: [[SimpleTest]]: [MySQL] 2,945 pass(es).
[ View ]

Here is the patch to uc_attributes adding Views filter for each attribute. The filters are in Product group. It searches uc_product_adjustments.combination column for substring using LIKE. Works with exposed filters.

docans’s picture

I have installed the patch and it works.

I am trying to find a solution to this issue https://drupal.org/node/2202341. With the pathc i can see a way to filter products that have an attribute associated with them.

Is there a way to filter based on Attribute options that are in a cart. Please refer to the issue at https://drupal.org/node/2202341 for more details.

Thanks

hockey2112’s picture

I installed the patch from #17 and it did add the attributes as filters in the View. However, when I choose any of those attributes in my exposed-filter search box and run a search, it returns no results. I definitely have products that have those attributes assigned... what would cause them to not show up in the search results?

Basically, here's what I was expecting to happen:

  1. Product A has "blue" as an available option in its "Color" attribute.
  2. When I choose "blue" from the exposed filter for my Products view, Product A should show up in the search results since it has "blue" as an available option.

Instead, zero results were returned.

Here's a link to my testing site: http://192.185.163.44/~drupal72/?q=product-search
It is a fresh Drupal 7.26 installation with only these contrib modules installed:
Ctools (latest version)
Entity (latest version)
Rules (latest version)
Ubercart (7.x-3.x-dev from 2014-Jan-18)
Views (latest version)

Here's an export of my View, in case it might be helpful:

$view = new view();
$view->name = 'product_search';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Product Search';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Product Search';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Title */
$handler->display->display_options['sorts']['title']['id'] = 'title';
$handler->display->display_options['sorts']['title']['table'] = 'node';
$handler->display->display_options['sorts']['title']['field'] = 'title';
$handler->display->display_options['sorts']['title']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'product' => 'product',
);
/* Filter criterion: Product: Attribute: Color */
$handler->display->display_options['filters']['attr_1']['id'] = 'attr_1';
$handler->display->display_options['filters']['attr_1']['table'] = 'uc_product_adjustments';
$handler->display->display_options['filters']['attr_1']['field'] = 'attr_1';
$handler->display->display_options['filters']['attr_1']['exposed'] = TRUE;
$handler->display->display_options['filters']['attr_1']['expose']['operator_id'] = 'attr_1_op';
$handler->display->display_options['filters']['attr_1']['expose']['label'] = 'Color';
$handler->display->display_options['filters']['attr_1']['expose']['operator'] = 'attr_1_op';
$handler->display->display_options['filters']['attr_1']['expose']['identifier'] = 'attr_1';
$handler->display->display_options['filters']['attr_1']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['path'] = 'product-search';
$handler->display->display_options['menu']['type'] = 'normal';
$handler->display->display_options['menu']['title'] = 'Product Search';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['context'] = 0;

hockey2112’s picture

StatusFileSize
new12.6 KB

I'm still stuck. Here are the patched (and new) files. Can someone take a quick look and let me know if anything is amiss? Thanks!

sin’s picture

hockey2112, can you post records from uc_product_adjustments database table? The patch searches it, I guess you should have some sku assigned to attribute combination.

hockey2112’s picture

sin,

That was the problem... I did not have SKUs assigned to the attribute options. Once I assigned the SKUs, the exposed filters worked perfectly.

Would it be possible to allow the exposed filters to work when options do not have SKUs assigned?

Thanks!

hanoii’s picture

StatusFileSize
new2.91 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/ubercart/uc_attribute/views/uc_attribute.views.inc.
[ View ]

I am doing some work with uc_attributes and views myself. I was once a developer in uc_views and most of it got included in D7 so now I kept contributing patches to ubercart. I wanted to combine this patch and my own, but I found some issues with it. The main thing that I found is that the filter relies on the product adjustment table, which might not always be the case. You could have products with attributes that doesn't get ever to the adjustment table because they might not get it's own SKU.

The filter should rather apply to the uc_product_attribute_option table instead.

Only if interesting to someone, I am currently working in a master/slave set of sites in which one master ubercart site should feed product details to a bunch of slave sites. A lot of things is there but the output of attributes was missing. What I worked on was a way to output the price, cost and weight of each product option to views so that it can be added to a feed.

I was also accepted in uc_feeds so I will contribute some things there as well, but it already has some good attributes support.

I wasn't sure if I should open a second issue or share my patch here, so I am gonna start with here, if better to follow it up separately on a different issue, I can upload it then.

Status:Needs review» Needs work

The last submitted patch, 23: 895236-exposing-cost-weight-price-attributes-on-views.patch, failed testing.

hanoii’s picture

StatusFileSize
new2.91 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/ubercart/uc_attribute/views/uc_attribute.views.inc.
[ View ]

patch without that php error that was added accidentally

TR’s picture

Status:Needs work» Needs review

Status:Needs review» Needs work

The last submitted patch, 25: 895236-exposing-cost-weight-price-attributes-on-views.patch, failed testing.

hanoii’s picture

StatusFileSize
new2.91 KB
FAILED: [[SimpleTest]]: [MySQL] 2,943 pass(es), 0 fail(s), and 77 exception(s).
[ View ]

I must have been tired with submitted and resubmitted previous patch, now for real, without the php issue.

hanoii’s picture

Status:Needs work» Needs review

Status:Needs review» Needs work

The last submitted patch, 28: 895236-exposing-cost-weight-price-attributes-on-views.patch, failed testing.

hanoii’s picture

Status:Needs work» Needs review
StatusFileSize
new2.93 KB
PASSED: [[SimpleTest]]: [MySQL] 2,941 pass(es).
[ View ]

Without the PHP notice

hanoii’s picture

StatusFileSize
new0 bytes
PASSED: [[SimpleTest]]: [MySQL] 2,945 pass(es).
[ View ]

Improved patch that adds additional fields to the weight handler of the attributes as well as adding more data to the field handlers for being float and sortable.

hanoii’s picture

StatusFileSize
new3.28 KB
PASSED: [[SimpleTest]]: [MySQL] 2,945 pass(es).
[ View ]

#32 patch was empty, attaching a new one.

hanoii’s picture

jodyfr’s picture

Many thanks for providing the patch in #33. Is there a way to enable the views support without uninstalling and re-installing the uc_attribute module? I've applied the patch manually, updating uc_attribute.module and creating the new uc_attribute.views.inc file in the uc_attribute folder. I cleared my cache but still don't see any attribute field options in my product view.

hanoii’s picture

there's a views clear cache button in the advanced settings of views, but clearing all caches should have cleared it. Bear in mind this patch only exposes fields, not filters, not sure which one you were using.

hockey2112’s picture

Can this functionality (filter by attributes) be added to a View of type "Orders"? I added the new patches from #33 (and also tried the ones from #17), but cannot get the attributes to sow up as filters.

kopeboy’s picture

When this will be included in a stable release?

If I update to dev version can I use this functionality right away or do i have to disable/re-enable anything?
Thanks

sin’s picture

StatusFileSize
new3.66 KB
PASSED: [[SimpleTest]]: [MySQL] 2,951 pass(es).
[ View ]

I rewrote my patch so it now queries uc_product_options table instead of uc_product_adjustments. SKU for attributes is not required now. But I have to use subqueries so there might be performance issues with this variant.

I tested only filter product nodes by attribute options, both single values and multiple selected values with OR works. Attributes as fields and arguments are not tested.

hockey2112, orders might work if you add a relation to product nodes in your view.

hanoii, if you can review my patch again and combine with yours that would be awesome :)

Colin @ PCMarket’s picture

Have been able to apply the patches supplied here on to a 3.7 installation and even after clearing caches cannot seem to get attribute exposed to views fields.

am i missing something here?

mattbk’s picture

I'm not seeing any new fields either, unfortunately. Patched #33 onto 7.x-3.x-dev, 10 Sep 2014.

EDIT: It also made the attributes no longer appear on the product pages, so I repaired from backup.

bellagio’s picture

StatusFileSize
new31.07 KB

after applying the patch #39, i see the attribute exposed to views fields, but my views disappears from content bottom block... When attribute field is removed, my views appears again.