I have a feature with an exported custom line item type. When I run "drush features" or go to /admin/structure/features the feature is listed as overridden, even though the line item type exists and there have been no changes to it. Reverting the feature does not change the status. Using the diff module, it appears that features thinks the line item type should not exist:

Commerce line item feature diff

Comments

BassistJimmyJam’s picture

Status: Active » Closed (works as designed)

Looks like my export was missing "'module' => 'commerce_custom_line_items'" from the line item type definition. Adding it resolved the override. Not sure where it went missing, but it may have been exported for an older patch of the line items type export than what was actually committed.

caktux’s picture

Status: Closed (works as designed) » Active

I'm also having this problem but using commerce_custom_product, and it is included in the dependencies. The diff shows an empty array and not FALSE, and reverting creates an empty line item type.

bojanz’s picture

@caktux
Can you attach your feature (or at least the relevant parts)? Also, a screenshot of the diff screen?

caktux’s picture

StatusFileSize
new29.9 KB

Mais bien sur!

screenshot

/**
 * Implements hook_commerce_line_item_default_types().
 */
function yogamonde_gift_certificates_commerce_line_item_default_types() {
  $items = array(
    'gift_certificate' => array(
      'name' => 'Certificat cadeau',
      'description' => 'A customizable product line item type.',
      'product' => TRUE,
      'add_form_submit_value' => 'Ajouter un produit',
      'base' => 'commerce_product_line_item',
    ),
  );
  return $items;
}
fabianx’s picture

This problem is two-fold:

a) Things never get written to the Database, because the 'type' is not set and drupal_write_record gives an error.
b) Things never get written to the Database, because commerce_features implements commerce_features_commerce_line_item_type_info_alter

This is wrong.

Things need to live in the database for this to work.

To fix this do:

- Remove commerce_features_commerce_line_item_type_info_alter completely

Apply the following pseudo-patch:

/**
 * Implements hook_features_revert().
 */
function commerce_line_item_type_features_revert($module) {
  // Get default line item types
  if (module_hook($module, 'commerce_line_item_default_types')) {
    $default_types = module_invoke($module, 'commerce_line_item_default_types');
    foreach ($default_types as $type => $line_item_type) {
+      $line_item_type['type'] = $type;
      commerce_custom_product_line_item_type_save($line_item_type, TRUE, TRUE);

Real patch coming ...

fabianx’s picture

Priority: Normal » Critical

Setting status to critical. This is unusable without these fixes.

fabianx’s picture

Status: Active » Needs review
StatusFileSize
new2.08 KB

Issue #1450910: Fix export of line items.

* Remove commerce_features_commerce_line_item_type_info_alter hook. This
prevented reverting the feature and write to DB.
* Add type info to $line_item_type to make drupal_write_record working.

This fixes three bugs:

* Line items show as overridden on re-export.
* Line items are removed from feature on re-export (on fresh site).
* Error while reverting feature.

fabianx’s picture

FWIW,

I work-arounded this for now for me by implementing:

/**
 * Implements hook_module_implements_alter().
 *
 * @todo: Remove once http://drupal.org/node/1450910#comment-7342652 has been fixed.
 */
function mymodule_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'commerce_line_item_type_info_alter') {
    // Remove alter hook from commerce_features, it breaks things.
    unset($implementations['commerce_features']);
  }
}

and adding the type key statically to my feature. (which shows up as overridden but I can live with that)

aschiwi’s picture

I can confirm this problem. @Fabianx: Your patch fixes this problem for us. The line item comes in as expected and the feature stays clean. Thanks for the patch.

fastangel’s picture

The patch of #7 work for me but the provisional solution of #8 not :(

vasike’s picture

Status: Needs review » Reviewed & tested by the community

indeed the #7's patch seems to work.

there's also a related issue about this : #1919014: Unable to enable module using latest versions of required modules..
the patch there no more needed if this patch is commited.

bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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

Lloyd_87’s picture

Hi,

sorry to reopen an old thread, but i too am having the problem above. could you possibly assist.

thanks