Skip to content

Instantly share code, notes, and snippets.

@mneuhaus
Last active June 15, 2017 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mneuhaus/ffb4373560d2c11ba5280aa18d5c4324 to your computer and use it in GitHub Desktop.
Save mneuhaus/ffb4373560d2c11ba5280aa18d5c4324 to your computer and use it in GitHub Desktop.
<?php
class ProductMapping extends AbstractMapping {
/**
* Type/Name of the coremedia content
*
* @var string
*/
protected $sourceType = 'pim_product';
/**
* ClassName of the Entity a Coremedia Items gets mapped to
*
* @var string
*/
protected $targetEntity = '\My\Namespace\Domain\Model\Product';
/**
* Fields to be mapped to the target entity
*
* @var array
*/
protected $fields = [
'name' => [
'property' => 'name'
],
'creationDate' => [
'property' => 'crdate',
'converter' => 'dateToTimestamp'
]
];
public function dateToTimestamp($date, $field) {
... convert $date into a timestamp and return the value
}
}
class ArticleMapping extends AbstractMapping {
/**
* Type/Name of the coremedia content
*
* @var string
*/
protected $sourceType = 'pim_article';
/**
* ClassName of the Entity a Coremedia items gets mapped to
*
* @var string
*/
protected $targetEntity = '\My\Namespace\Domain\Model\Article';
/**
* Fields to be mapped to the target entity
*
* @var array
*/
protected $fields = [
'name' => [
'property' => 'name'
],
'product' => [
'property' => 'product',
'converter' => 'oneToMany',
'targetEntity' => '\My\Namespace\Domain\Model\Product'
]
];
public function oneToMany($product, $field) {
... resolve relation to targetEntity ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment