Hello. In mapping, there is no target on the field_price in commerce. I solved this problem by taking the CommercePrice.php file from githab under the link https://github.com/politsin/commerce_feeds. Replaced one line and everything works. Is it possible to add this default target to feeds?

<?php

namespace Drupal\feeds\Feeds\Target;

use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\feeds\FieldTargetDefinition;
use Drupal\feeds\Plugin\Type\Target\FieldTargetBase;

/**
 * Defines a link field mapper.
 *
 * @FeedsTarget(
 *   id = "commerce_price",
 *   field_types = {"commerce_price"}
 * )
 */
class CommercePrice extends FieldTargetBase {

  /**
   * {@inheritdoc}
   */
  protected static function prepareTarget(FieldDefinitionInterface $field_definition) {
    return FieldTargetDefinition::createFromFieldDefinition($field_definition)
      ->addProperty('number')
      ->addProperty('currency_code');
  }

  /**
   * {@inheritdoc}
   */
  protected function prepareValue($delta, array &$values) {
    $values['number'] = trim($values['number']);
    if(!is_numeric($values['number'])){
      $values['number'] = false;
    }
  }

}

Comments

lexsaenko created an issue. See original summary.

megachriz’s picture

Status: Active » Closed (works as designed)

This has already been implemented in Commerce Feeds. I released a D8 version of that module just a few days ago.

lexsaenko’s picture

Oh sorry, I knew about this module but for version 7. Thank you very much for the module for 8 branches :)