I can't seem to create an product class from an advertisement content type.

I get this:
This is a node type provided by another module. Only custom node types may become product classes.

Is there anyway around this

Comments

SocialNicheGuru’s picture

I modified this line in the following function.

What is the thought behind not making products out of node types created by other modules? Is it because there might be some custom code?

function uc_product_class_form_validate($form, &$form_state) {
if ($form['pcid']['#type'] == 'textfield') {
$type = node_get_types('type', $form_state['values']['pcid']);
if ($type) {
if ($type->module == 'uc_product') {
form_set_error('pcid', t('This product class already exists.'));
}
elseif ($type->custom == 0) {

// form_set_error('pcid', t('This is a node type provided by another module. Only custom\
node types may become product classes.'));
}
}
}
}

Island Usurper’s picture

Status: Active » Closed (works as designed)

Right. Once you make a node type a product class, it uses uc_product's node hooks instead of the module that created it. Advertisements, images, events, these all have special functionality in their modules, and turning them into products would break them.

Damien Tournoud’s picture

Title: Can't make a Product Class from advertisement content type » Allow any node type to become a product
Category: bug » feature
Status: Closed (works as designed) » Postponed

The reasoning is sound, but this needs to be fixed in 3.x ;)

Stutzer’s picture

So have anyone found decision of this problem? I just bumped with the same issue — can not make my_module content type a product.

TR’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Postponed » Active

Moving to the Ubercart 3.x issue queue. The current behavior will not be changed for Ubercart 2.x.

grasmash’s picture

Subscribe. This would be an excellent feature.

jwilson3’s picture

Subscribe.

As soon as you export a custom Content Type to code (eg with the Feature module), it becomes a module's Content Type, and no longer is a candidate for Ubercart product classization. You get the error mentioned above.

Similarly, a custom content type that has been 'classized' into being an Ubercart-able product is no longer able to be exported to Features. Note that custom attached CCK fields *can* still be exported to Features. I'm talking about the content type definition that typically gets put in [feature_name].features.inc: [feature_name]_node_info().

Edit: Clarified the post with more details about features.

jwilson3’s picture

Found a workaround for exporting the Content Type definitions to features.

I'm using the hook_enable() function inside [feature_name].install file to "build" the content type programmatically.

See sample code (part of the COD):

http://drupalcode.org/viewvc/drupal/contributions/modules/cod_support/co...

and related ticket:

#784404: Add date field to event content type and associate with signup.module

ezra-g’s picture

noahlively’s picture

Check out this Drupal 7 implementation of the uc_donation module:

/**
 * Implements hook_load().
 */
function uc_donation_load($nodes) {
  uc_product_load($nodes);
}

// ........

/**
 * Implements hook_product_types().
 */
function uc_donation_uc_product_types() {
  return array_keys(uc_donation_node_info());
}

This allows donation nodes to function as products. Does this answer the question?

longwave’s picture

giorgio79’s picture

#298890: Ubercart: "Product classes" or "Product types"? was also marked as duplicate
webchick summed it up perfectly

do away with the concept of "Product class" altogether, in favour of just using regular old node types, which Drupalers already understand. The product association could be done by:

1. A checkbox on the node type form to declare "This content type is an Ubercart product."
2. A settings page under Administer >> Store administration >> Products someplace that lists all the node types in the system with checkboxes next to them to declare them as product types.
3. Make the product settings a CCK field that can be added to any node type.
etc.

A plethora of options available ;) any one of them less confusing than the concept of "Product Classes.

This could work very well given content types are also entities in D7.

SocialNicheGuru’s picture

can I make any entity a product using ubercart for drupal 7?

Alan D.’s picture

What are the functional differences between a "product class" node entity type and the default product content type?

A great abstraction out would allow multiple classes to be assigned, and the single uniting class being the product class that defines that a content type can have a price, id, etc (and enforced I guess). Another class would be a attributed product (for lack of a better name) that allows a type to have assigned attributes, ...