You are here

README.txt in Node import 5

Drupal node_import/supported/ecommerce README.txt
==============================================================================

This directory contains support files for the ecommerce module bundle.

Thanks to these support files, node_import is able to import following
ecommerce products:
 - tangible (shippable product).

Code explanation
------------------------------------------------------------------------------

The products family of node content types have one big problem: the
$node->type is always set to 'product' for each ecommerce product. The
product.module itself does not support any node content types by itself,
rather other modules extend the basic functionality of product.module.

These extented products get their product-name in $node->ptype rather
then $node->type.

In order for node_import to work, ecommerce product support files need to
do the following:

1. In hook_node_import_types() return a list of product types yourproduct
   module provides where you set $type equals to $node->ptype. So instead
   of returning:

   array('product' => t('Your product');

   you need to return

   array('yourproduct' => t('Your product');

   even though $node->type == 'product' and $node->ptype == 'yourproduct'.

2. In hook_node_import_fields() only return a list of fields that the
   yourproduct module provides; do not include the fields product.module
   supports. The $type will be set to 'yourproduct' rather then
   'product' here.

3. In hook_node_import_global() $type will be set to 'yourproduct'. Again
   only provide the options you need for yourproduct without including
   the ones provided by product.module.

4. In hook_node_import_static() $type will be set to 'yourproduct'.

5. In hook_node_import_prepare() you can assume that $node->type will be
   set to 'product' and $node->ptype to 'yourproduct'.

The reason this will work is because $type is only used internally inside
node_import for most hooks. In addition, product.inc will do some magic
behind the scene:

1. In product_node_import_static() we will copy $node->type into
   $node->ptype and set $node->type to 'product'. This makes it so that
   all things are "normal" in hook_node_import_prepare().

2. In product_node_import_fields() we will invoke for $type = 'product'
   all hook_node_import_fields() of other modules. Eg, taxonomy.module
   assumes that vocabularies are attached to the 'product' node type
   rather then the 'yourproduct' node type (which does not exist).

3. In product_node_import_global() we do the same.

4. In product_node_import_static() we do the same.

File

supported/ecommerce/README.txt
View source
  1. Drupal node_import/supported/ecommerce README.txt
  2. ==============================================================================
  3. This directory contains support files for the ecommerce module bundle.
  4. Thanks to these support files, node_import is able to import following
  5. ecommerce products:
  6. - tangible (shippable product).
  7. Code explanation
  8. ------------------------------------------------------------------------------
  9. The products family of node content types have one big problem: the
  10. $node->type is always set to 'product' for each ecommerce product. The
  11. product.module itself does not support any node content types by itself,
  12. rather other modules extend the basic functionality of product.module.
  13. These extented products get their product-name in $node->ptype rather
  14. then $node->type.
  15. In order for node_import to work, ecommerce product support files need to
  16. do the following:
  17. 1. In hook_node_import_types() return a list of product types yourproduct
  18. module provides where you set $type equals to $node->ptype. So instead
  19. of returning:
  20. array('product' => t('Your product');
  21. you need to return
  22. array('yourproduct' => t('Your product');
  23. even though $node->type == 'product' and $node->ptype == 'yourproduct'.
  24. 2. In hook_node_import_fields() only return a list of fields that the
  25. yourproduct module provides; do not include the fields product.module
  26. supports. The $type will be set to 'yourproduct' rather then
  27. 'product' here.
  28. 3. In hook_node_import_global() $type will be set to 'yourproduct'. Again
  29. only provide the options you need for yourproduct without including
  30. the ones provided by product.module.
  31. 4. In hook_node_import_static() $type will be set to 'yourproduct'.
  32. 5. In hook_node_import_prepare() you can assume that $node->type will be
  33. set to 'product' and $node->ptype to 'yourproduct'.
  34. The reason this will work is because $type is only used internally inside
  35. node_import for most hooks. In addition, product.inc will do some magic
  36. behind the scene:
  37. 1. In product_node_import_static() we will copy $node->type into
  38. $node->ptype and set $node->type to 'product'. This makes it so that
  39. all things are "normal" in hook_node_import_prepare().
  40. 2. In product_node_import_fields() we will invoke for $type = 'product'
  41. all hook_node_import_fields() of other modules. Eg, taxonomy.module
  42. assumes that vocabularies are attached to the 'product' node type
  43. rather then the 'yourproduct' node type (which does not exist).
  44. 3. In product_node_import_global() we do the same.
  45. 4. In product_node_import_static() we do the same.