This is probably due to recent changes in Views3, but you can't (successfully) create a views relationship from a node with a product reference to the product reference.

Three different relationships are offered:

rfay_screenshot_sony_Selection_004.png

Unfortunately, none of these relationships actually provide access to the data in the product. They all result in sql errors.

The attached patch is what I did to fix this problem in Amazon... Unfortunately it doesn't do the job here. Will have to consult with @dereine yet again.

Setting to needs review just because there's a patch. But the patch does not in fact work.

Comments

rfay’s picture

Status: Needs review » Needs work

Of course this should be "Needs work". I'll try to catch dereine when he's on and ask how this should work.

dawehner’s picture

In general your patch looks fine.

i'm wondering whether fieldapi fields should have a special key so it can be detected easy

rfay’s picture

Thanks for looking at this @dereine. Unfortunately even with the patch we get nowhere. We get down to two offered relationships:
rfay_screenshot_sony_Selection_005.png

Here's what the names look like after they're added:
rfay_screenshot_sony_Selection_006.png

But we get this error as soon as we try to do anything:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_product.field_product' in 'on clause'

rfay’s picture

Status: Needs work » Needs review

Well, call me crazy, but now that I posted that I have only one relationship offered, and it works (or comes closer to working)

I'm baffled.

rszrama’s picture

StatusFileSize
new2.37 KB

I wanted to update this for our other reference field relationships and noticed I was still getting duplicates for line items. It turns out one of the relationships is for the delta value of a multi-value field. How does the attached patch look, manually filtering out "delta" as an option?

rfay’s picture

Title: Views relationship on product reference is broken » Views relationships are broken; update all

Looks OK to me. Looking forward to what dereine has to say.

damien tournoud’s picture

Title: Views relationships are broken; update all » Views relationships are broken; update all; add tests

Just saying.

damien tournoud’s picture

Status: Needs review » Needs work

Also:

  • Those look that they should use hook_field_views_data_alter($result, $field, $module)
  • Why are we adding the relationships several times per table? Only once attached to the proper column should be enough.
aem34’s picture

hello,

this is also what i described in :
#1114764 : Error when adding an existing field to cart view
(post #7)

rfay’s picture

Status: Needs work » Reviewed & tested by the community

I've tested this quite thoroughly and am happy with it. Seems to be working fine.

After commit, let's set it back to needs work and make a test for it.

rszrama’s picture

Title: Views relationships are broken; update all; add tests » Views relationships are duplicated; update all; add tests
Status: Reviewed & tested by the community » Needs work

Alrighty, committed the fix, and let's figure out a way to build tests. Also, I think the title was a bit of a misnomer... the relationships themselves weren't broken as far as I could tell but were being duplicated. I almost feel like testing should've just been a separate issue.

rszrama’s picture

Title: Views relationships are duplicated; update all; add tests » Add tests for Views relationships
Category: bug » task
Status: Needs work » Active

Just doing some triage. Rereading my comment above, let's just fully repurpose this issue so the title isn't confusing any more.

rszrama’s picture

Component: Product reference » Views integration
tim.plunkett’s picture

Issue summary: View changes

Fixing input format.

bojanz’s picture

Status: Active » Closed (outdated)