There are several problems with product classes in order for them to be usable. On the store administrative page is listed Manage Classes (admin/store or click on Store in the admin menu). The description says "Create and edit product node types." When clicking on this link there is a list of product classes which have links for editing. But no where is there anything to create a product class. It is possible to create a product class by creating a new content type. In the vertical tabs is listed Ubercart product settings and there is a checkbox "Content type is product." It took me a long time to find this and if this is how product classes are intended to be created it is safe to say they will almost never be used. It is also possible to create a product class programmatically but that is not something most users would be able to do. So Manage classes should provide a simple way to create a product class. I thought about just providing a link to the NodeTypeForm but the default settings will not create a product class. Even if I could figure out a way to use the form with the checkbox enabled I think it is still way too complex. So I created a simplified form with the name, machine name and description. This allows product classes to be created quickly and they can always edit it once it is created to add additional functionality. But there is room for some other thoughts on the best way to add a product class.

A patch will be included in the next comment.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

trobey created an issue. See original summary.

trobey’s picture

TR’s picture

Category: Bug report » Feature request
trobey’s picture

The first screenshot shows the Ubercart menu in Drupal 7. The Manage classes item has the description "Create and edit product node types." Clicking on this link we get the second screenshot. This page lists the product classes and then has an Add a class form. The form has fields for class ID, class name and description.

The third screenshot shows the Ubercart menu in Drupal 8. The Manage class item is identical to the one for Drupal 7. Clicking on this link we get the fourth screenshot. This page has a listing of the product classes but there is not place to create a product class. This conflicts with the description in the link.

After applying the patch the web page looks like the fifth screenshot. Now there is a link provided to Add a new product class. Clicking on the link takes us to the sixth screenshot. Here we see a field for product class name and description (the machine name is automatically added to the form).

The patch provides the missing functionality that existed for Ubercart in Drupal 7. The only difference is that the form is on a separate page then the listing. This seems consistent with the way Drupal 8 does things. As can be seen there is no new functionality provided by this patch; it merely provides the same functionality that Ubercart had for Drupal 7.

TR’s picture

I agree, this is a big improvement. Thanks for the patch!

I would like a functional test for the new form before I commit this.

There are a bunch of other things that could be done to improve the user experience here:

  1. Some explanatory text on the product classes form with a short description of what a class is, why to create one, and a link to the full product class documentation on drupal.org.
  2. Text appended to a product class type description stating that this is a Ubercart product type - that way this is obvious from the manage content types screen.
  3. Vertical tab summary text on the content type manage page, stating whether or not the (hidden) "Make this a product" checkbox is checked.
  4. Make existing type a product class functionality on the manage product classes page.
TR’s picture

This patch modifies the patch from #2 to use short array syntax (the current Drupal coding standard) and uses $this->t() instead of t(). I also added a line to the submitForm() function to save the description text, as it wasn't being saved.

I also added the table of existing classes to the bottom of the "Add a product class" page, so it looks more like D7 and because I find having the list of existing classes useful when I'm creating a new class.

I added some Javascript to do the tab summaries (item 3 above) and to append text to the content type description (item 2 above).

No tests yet, and no progress yet on items 1 and 4 above - just posting this for the testbot to tell me if I made any mistakes so far.

TR’s picture

Perhaps we could go even further and eliminate the specialized product class forms, instead do everything from the normal content type administration pages? The "Add a new product class" action could be added to the top of the content types page, and the store admin menu "Manage product classes" could take the user directly to the content types page.

See also #404416: Add a simple form to /admin/store/products/classes to add a class

starlightE’s picture

In D8.4. 4, Ubercart 8.x-4.0-alpha5

An Ubercart Product Class is created by adding a New Content type made from admin/structure/types/"add content"
and setting the new content type to be an ubercart "product". This new content type then shows up
in the ubercart/manage classes page. It took a while to discover that.

In ubercart/manage classes page the CLASS ID column shows the MACHINE ID that is found in admin/structure/content types edit page

in ubercart/manage classes, clicking the EDIT button in the "Operations" column takes the user to admin/structure/types/manage/xyz product

The use of different terminology CLASS vs Content Type is confusing. So is CLASS ID vs MACHINE ID ..

IMHO the Ubercart Class should be renamed from "Manage Classes" to "Manage Product Content Types" with a hover title reference to content types and CLASS ID should be renamed MACHINE ID, with a hover description "As shown in the Structure/Types page"and "Operations" should be renamed "Content", then users would quickly derive associations with little wasted time.

Having an "ADD Classes button" labeled "Add Product Content Type" would be real nice too.

Personally, to me, given the voluminous amount of things to understand in Drupal, its better to not introduce a new word "Class"
when its functionally a "Content type". its a little war of words, but i hope for consistency most of all. Drupal is great!

TR’s picture

its better to not introduce a new word "Class" when its functionally a "Content type".

Just to be perfectly clear:

  • Ubercart had the concept of Product Class back in Drupal 5. Drupal core did not have content types back then.
  • Ubercart also had the concept of Product Class in Drupal 6. Drupal core did not have content types back then, but the contributed module CCK could be used to create CCK node types.
  • Ubercart also had the concept of Product Class in Drupal 7. Drupal core introduced content types in D7, but they didn't have all the functionality we needed in Product Classes.
  • It is only in Drupal 8 that core Drupal types may be simply used as Product Classes, and that the two terms are now almost the same.

However, the whole point of this issue is that if we do treat product classes identically to content types, then there is confusion and difficulty of use as the original poster and you both say. Additionally, people who have used Ubercart for years will see this as a missing feature. So we need a bridge between the two.

You can help out by testing the patch in #6 and commenting on the steps in #5.

nigelwhite’s picture

Patch #6 won't apply here. On composer install I get "Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2763535-6-product-class-add.patch".

At admin/store/products/classes there is no "Add a class" link, as it seems there should be according to documentation at https://www.drupal.org/docs/8/modules/ubercart/all-about-products/unders....

Drupal 8.6.4 Ubercart 4.0.0-alpha5

TR’s picture

@nigelwhite: "Patch #6 won't apply here."

No, you're wrong. I triggered a re-test of the patch in #6 and you can see in the above test results that the patch still applies to HEAD. I also tested this locally, and the patch still applies cleanly with no offsets or fuzz.

You must be trying to apply it to something other than HEAD.