You are here

public function FeedsCommerceProductMultiProcessor::newEntity in Commerce Feeds multitype 7

Creates a new product in memory and returns it.

Overrides FeedsCommerceProductProcessor::newEntity

File

plugins/FeedsCommerceProductMultiProcessor.inc, line 22
Class definition of FeedsCommerceProductMultiProcessor.

Class

FeedsCommerceProductMultiProcessor
Creates products of different types from feed items.

Code

public function newEntity(FeedsSource $source) {

  // Wrap parent::newEntity(), modifying the bundle setting if necessary.
  $bundle = $this
    ->getBundle($source);
  if ($bundle) {

    // Temporarily change $this->config['bundle'] to influence
    // parent::newEntity().
    $default = $this->config['bundle'];
    $this->config['bundle'] = $bundle;
  }
  $entity = parent::newEntity($source);
  if ($bundle) {

    // Revert to the old value.
    $this->config['bundle'] = $default;
  }
  return $entity;
}