You are here

function commerce_pricelist_feeds_entity_update in Commerce Pricelist 7

Implements hook_entity_update().

1 call to commerce_pricelist_feeds_entity_update()
commerce_pricelist_feeds_entity_insert in commerce_pricelist_feeds/commerce_pricelist_feeds.module
Implements hook_entity_insert().

File

commerce_pricelist_feeds/commerce_pricelist_feeds.module, line 141
Implements the basic functionality required to create and display an entity.

Code

function commerce_pricelist_feeds_entity_update($entity, $type) {

  // Source attached to entity.
  if ($type == 'commerce_pricelist_list') {
    if (isset($entity->feeds) && ($importer_id = commerce_pricelist_feeds_get_importer_id())) {
      $fake_nid = _commerce_pricelist_feeds_fake_nid($entity);
      $config = array(
        'FeedsCommercePricelistItemProcessor' => array(
          'list_id' => $entity->list_id,
        ),
      );
      $source = feeds_source($importer_id, $fake_nid);
      $source
        ->addConfig($entity->feeds);
      $source
        ->addConfig($config);
      $source
        ->save();

      // Start import if requested.
      if (feeds_importer($importer_id)->config['import_on_create'] && !isset($entity->feeds['suppress_import'])) {
        $source
          ->startImport();
      }

      // Schedule source and importer.
      $source
        ->schedule();

      //feeds_importer($importer_id)->schedule();
    }
  }
}