I have a node field for an Amazon item. When I create a node View, I add a relationship, and am presented with two very similar options:

Content: Amazon Item
Appears in: node:gift

and

Fields: Amazon Item (field_amazon_item) - asin
Appears in: node:gift

I'm not sure what the difference between them is, so I tried each.

I select "Content: ..." as the relationship.
I change "Show:" to "Fields".
I add "Amazon: product image" as a field, and get this in the preview section:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_amazon_item.field_amazon_item' in 'on clause'

And this when I try to view the page:

    *  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_amazon_item.field_amazon_item' in 'on clause'
    * Notice: Undefined variable: preview in views_ui_preview() (line 267 of /path/to/drupal/sites/all/modules/views/includes/admin.inc).
    * PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_amazon_item.field_amazon_item' in 'on clause': SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {node} node LEFT JOIN {field_data_field_amazon_item} field_data_field_amazon_item ON node.nid = field_data_field_amazon_item.entity_id AND (field_data_field_amazon_item.entity_type = :views_join_condition_0 AND field_data_field_amazon_item.deleted = :views_join_condition_1) LEFT JOIN {amazon_item} amazon_item_field_data_field_amazon_item ON field_data_field_amazon_item.field_amazon_item = amazon_item_field_data_field_amazon_item.asin LEFT JOIN {amazon_item_image} amazon_item_field_data_field_amazon_item__amazon_item_image ON amazon_item_field_data_field_amazon_item.asin = amazon_item_field_data_field_amazon_item__amazon_item_image.asin AND amazon_item_field_data_field_amazon_item__amazon_item_image.size = :views_join_condition_2 WHERE (( (node.status = :db_condition_placeholder_0) ))) subquery; Array ( [:db_condition_placeholder_0] => 1 [:views_join_condition_0] => node [:views_join_condition_1] => 0 [:views_join_condition_2] => smallimage ) in views_plugin_pager->execute_count_query() (line 140 of /path/to/drupal/sites/all/modules/views/plugins/views_plugin_pager.inc).

So I tried the same with the other relationship, "Field: ...":
I change the "Show:" to "Fields".
I add "Amazon: product image" as a field.

I get this, repeated for each node, when I try to view the page:

Notice: Undefined index: detailpageurl in views_handler->get_value() (line 275 of /Users/shawn/Library/MAMP/htdocs/drupal7_gifts/sites/all/modules/views/includes/handlers.inc).
CommentFileSizeAuthor
#5 amazon.relationship_ambiguity.patch920 bytesrfay

Comments

rfay’s picture

I believe this is true for *every* field. I thought it was a new views usability issue, but maybe it's something I'm doing wrong in the Views API. Another thing that got changed?

rfay’s picture

I just checked in a new version of the Amazon Example feature. It may help you as a basic for views. Still trying to sort out all the new Views 3 API changes.

rfay’s picture

Title: Confusing Views Relationship » Duplicate views relationship offering (and one doesn't work)

Dereine says that the code in asin.module's hook_views_data:

function asin_field_views_data($field) {
  $data = field_views_field_default_views_data($field);
  foreach ($data as $table_name => $table_data) {
    foreach ($table_data as $field_name => $field_data) {
      if (!in_array($field_name, array('table', 'entity_id', 'revision_id'))) {
        $data[$table_name][$field_name]['relationship'] = array(
          'handler' => 'views_handler_relationship',
          'base' => 'amazon_item',
          'base_field' => 'asin',
          'label' => t('ASIN from !field_name', array('!field_name' => $field['field_name'])),
        );
      }
    }
  }
  return $data;
}

entity_id, revision_id got renamed to field_<fieldname> and field_<fieldname>-revision_id

shawn dearmond’s picture

So this is very odd. Now, when I select the relationship "Fields: Amazon Item (field_amazon_item) - asin" I don't get any errors at all when I start adding fields.

Cool!

It's still weird that the other relationship is there, but I'm glad that this one isn't throwing errors anymore.

rfay’s picture

StatusFileSize
new920 bytes

OK, dereine helped me with a fix. This is *committed* already. Patch is attached.

rfay’s picture

Status: Active » Fixed

Please test with latest dev or with git clone and see if this solves the problem for you. Thanks.

shawn dearmond’s picture

Totally works! y'all rock!

PILIMILI’s picture

I would appreciate if i can get the complete file for asin.module no the patch i am not able for now to apply patches
thanks

rfay’s picture

@PILIMILI, you see that this is marked "fixed", that means it has already been committed and is in the dev release. In #5 I mentioned that it was already committed also.

In the future, to learn how to apply patches, use Git. Some Windows instructions are at http://drupal.org/node/150036. You use "git apply patchfile.patch"

The instructions at http://drupal.org/patch/apply haven't yet been updated for git.

PILIMILI’s picture

I am learning

rfay’s picture

PILIMILI++

PILIMILI’s picture

thanks in advance ,
I am not a developer I am learning from scratch if could you clarify for me please the below
" this is marked "fixed", that means it has already been committed and is in the dev release. In #5 I mentioned that it was already committed also."
so if "fixed" means running updated modules and is an update available for amazon and views it will fix the issue ??

rfay’s picture

Every 12 hours, a new dev release is created on the project page, http://drupal.org/project/amazon.

Right now you see there:

Development releases
Version 	Downloads 	Date 	Links
7.x-1.x-dev 	tar.gz (42.02 KB) | zip (59.04 KB) 	2011-Apr-15 	Notes | Edit
6.x-1.x-dev 	tar.gz (44.94 KB) | zip (63.29 KB) 	2011-Apr-15 	Notes | Edit

That means that on April 15 a commit was made and a new dev release created.

I don't know exactly how the automated updates will present these to you.

If you don't already know how to use IRC, you probably should learn how, as you could get much quicker answers to these things. http://drupal.org/irc.

PILIMILI’s picture

Impressive, thanks to show me this path. Every time i had amazon dev installed and run available recommended updates it changes to beta 5 how i could change so i gets only dev version??

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.