You are here

function uc_feeds_feeds_processor_targets_alter in Ubercart Feed Mappers 7

Implementation of hook_feeds_processor_targets_alter().

File

./uc_feeds.module, line 6

Code

function uc_feeds_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {

  // Proceed only if the content_type is a product type.
  if ($entity_type == 'node' && in_array($bundle_name, uc_product_types())) {

    // Model
    $targets['model'] = array(
      'name' => t('UC: Model/SKU'),
      'callback' => 'uc_feeds_set_target',
      'description' => 'Ubercart:' . t('Model/SKU'),
    );

    // List price
    $targets['list_price'] = array(
      'name' => t('UC: List price'),
      'callback' => 'uc_feeds_set_target',
      'description' => 'Ubercart:' . t('List price'),
    );

    // Cost
    $targets['cost'] = array(
      'name' => t('UC: Cost'),
      'callback' => 'uc_feeds_set_target',
      'description' => 'Ubercart:' . t('Cost'),
    );

    // Name
    $targets['Name'] = array(
      'name' => t('UC: Name'),
      'callback' => 'uc_feeds_set_target',
      'description' => 'Ubercart:' . t('Name'),
    );

    // Sell price
    $targets['sell_price'] = array(
      'name' => t('UC: Sell price'),
      'callback' => 'uc_feeds_set_target',
      'description' => 'Ubercart:' . t('Sell price'),
    );

    // Weight
    $targets['weight'] = array(
      'name' => t('UC: Weight'),
      'callback' => 'uc_feeds_set_target',
      'description' => 'Ubercart:' . t('Weight'),
    );
    $targets['weight_units'] = array(
      'name' => t('UC: Weight Unit'),
      'callback' => 'uc_feeds_set_target',
      'description' => 'Ubercart:' . t('Weight Unit'),
    );
    if (module_exists("uc_stock")) {
      $targets['uc_feeds_stock_sku'] = array(
        'name' => t('UC Stock: SKU'),
        'callback' => 'uc_feeds_set_target',
        'description' => t('An SKU column to update stock information. If missing, product\'s nid and main SKU will be used'),
      );
      $targets['uc_feeds_stock_active'] = array(
        'name' => t('UC Stock: Active'),
        'callback' => 'uc_feeds_set_target',
        'description' => t('If stock control should be active or not for the product.'),
      );
      $targets['uc_feeds_stock_stock'] = array(
        'name' => t('UC Stock: Stock'),
        'callback' => 'uc_feeds_set_target',
        'description' => t('The actual stock for the main or provided Stock SKU'),
      );
      $targets['uc_feeds_stock_threshold'] = array(
        'name' => t('UC Stock: Threshold'),
        'callback' => 'uc_feeds_set_target',
        'description' => t('The stock threshold in which notifications will be sent as configured.'),
      );
    }

    // Attributes
    if (module_exists("uc_attribute")) {
      $targets['attribute_combinations'] = array(
        'name' => t('UCA: Combinations'),
        'callback' => 'uc_feeds_set_target',
        'description' => 'Ubercart:' . t('Combination of attributes'),
      );
      $attribs = uc_attribute_load_multiple();
      foreach ($attribs as $attrib) {
        $aid = $attrib->aid;
        foreach ($attrib->options as $option) {
          $oid = $option->oid;

          // Attribute Price
          $targets['attribute_price_' . $aid . "_" . $oid] = array(
            'name' => t('UCA: Attribute !attr: Option !option: Price', array(
              '!attr' => $attrib->name,
              '!option' => $option->name,
            )),
            'callback' => 'uc_feeds_set_target',
            'description' => 'Ubercart attributes:' . t('Price for !attr/!option', array(
              '!attr' => $attrib->name,
              '!option' => $option->name,
            )),
          );

          // Attribute Cost
          $targets['attribute_cost_' . $aid . "_" . $oid] = array(
            'name' => t('UCA: Attribute !attr: Option !option: Cost', array(
              '!attr' => $attrib->name,
              '!option' => $option->name,
            )),
            'callback' => 'uc_feeds_set_target',
            'description' => 'Ubercart attributes:' . t('Cost for !attr/!option', array(
              '!attr' => $attrib->name,
              '!option' => $option->name,
            )),
          );

          // Attribute Weight
          $targets['attribute_weight_' . $aid . "_" . $oid] = array(
            'name' => t('UCA: Attribute !attr: Option !option: Weight', array(
              '!attr' => $attrib->name,
              '!option' => $option->name,
            )),
            'callback' => 'uc_feeds_set_target',
            'description' => 'Ubercart attributes:' . t('Weight for !attr/!option', array(
              '!attr' => $attrib->name,
              '!option' => $option->name,
            )),
          );
        }
      }
    }
  }
}