Download & Extend

Limit Products fields in the Product display "Manage Display" to the field of selected Product types

Project:Drupal Commerce
Version:7.x-1.x-dev
Component:Product reference
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:kickstart blocker

Issue Summary

The Manage Display of a Product Display type should check the Referenced Product Type field to only show the available fields for the selected Product Types.

source issue: #1629966: Check the allowed types of referenced product when managing content type display.

Comments

#1

Status:active» needs review

here is a patch
it limits the fields to the referenced product types, based on the instance of the product_reference field
and all fields of all product types if there is no product type selected.

AttachmentSizeStatusTest resultOperations
referenced_product_types_fields_for_display-1672118-1.patch2.96 KBIdlePASSED: [[SimpleTest]]: [MySQL] 3,589 pass(es).View details

#2

+        $referenceable_types = $field_instance['settings']['referenceable_types'];
+        foreach ($referenceable_types as $key => $referenceable_type) {
+          if ($referenceable_type) {
+            $product_types[] = $referenceable_type;
+          }
+        }

You can replace this with
$referenceable_types = array_filter($field_instance['settings']['referenceable_types']);

Might make sense to not duplicate the field adding code, and just give it a list of all product bundles if the list of referenceable types is empty, but that's more of a code style issue...

#3

thank you Bojan.
what about this new patch?

AttachmentSizeStatusTest resultOperations
referenced_product_types_fields_for_display-1672118-3.patch1.62 KBIdlePASSED: [[SimpleTest]]: [MySQL] 3,589 pass(es).View details

#4

Much better! Other than perhaps documentation tweaks, this seems ready.

#5

Status:needs review» reviewed & tested by the community

Let's get this to Ryan.

#6

Tagging.

#7

Status:reviewed & tested by the community» fixed

Touched up the comments and also used commerce_product_types() to get a list of "all" product types in the event no filter has been applied. For some reason as written it wasn't working in my testing.

Commit: http://drupalcode.org/project/commerce.git/commitdiff/957a599

#8

Status:fixed» closed (fixed)

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