| @@ 36-93 (lines=58) @@ | ||
| 33 | * @link https://github.com/techdivision/import |
|
| 34 | * @link http://www.techdivision.com |
|
| 35 | */ |
|
| 36 | class AttributeSetLoader implements LoaderInterface |
|
| 37 | { |
|
| 38 | ||
| 39 | /** |
|
| 40 | * The attribute sets. |
|
| 41 | * |
|
| 42 | * @var array |
|
| 43 | */ |
|
| 44 | protected $attributeSets = array(); |
|
| 45 | ||
| 46 | /** |
|
| 47 | * Construct that initializes the iterator with the import processor instance. |
|
| 48 | * |
|
| 49 | * @param \TechDivision\Import\Services\ImportProcessorInterface $importProcessor The import processor instance |
|
| 50 | */ |
|
| 51 | public function __construct(ImportProcessorInterface $importProcessor) |
|
| 52 | { |
|
| 53 | ||
| 54 | // load the entity types |
|
| 55 | $entityTypes = $importProcessor->getEavEntityTypes(); |
|
| 56 | ||
| 57 | // prepare the array with the attribute sets |
|
| 58 | foreach ($entityTypes as $entityType) { |
|
| 59 | foreach ($importProcessor->getEavAttributeSetsByEntityTypeId($entityType[MemberNames::ENTITY_TYPE_ID]) as $attributeSet) { |
|
| 60 | $this->attributeSets[$entityType[MemberNames::ENTITY_TYPE_CODE]][] = $attributeSet[MemberNames::ATTRIBUTE_SET_NAME]; |
|
| 61 | } |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Loads and returns data the custom validation data. |
|
| 67 | * |
|
| 68 | * @param \TechDivision\Import\Configuration\ParamsConfigurationInterface $configuration The configuration instance to load the validations from |
|
| 69 | * |
|
| 70 | * @return \ArrayAccess The array with the data |
|
| 71 | */ |
|
| 72 | public function load(SubjectConfigurationInterface $configuration = null) |
|
| 73 | { |
|
| 74 | ||
| 75 | $entityTypeCode = $configuration->getExecutionContext()->getEntityTypeCode(); |
|
| 76 | ||
| 77 | if (isset($this->attributeSets[$entityTypeCode])) { |
|
| 78 | return $this->attributeSets[$entityTypeCode]; |
|
| 79 | } |
|
| 80 | ||
| 81 | return array(); |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * Return's the import processor instance. |
|
| 86 | * |
|
| 87 | * @return \TechDivision\Import\Services\ImportProcessorInterface The processor instance |
|
| 88 | */ |
|
| 89 | protected function getImportProcessor() |
|
| 90 | { |
|
| 91 | return $this->importProcessor; |
|
| 92 | } |
|
| 93 | } |
|
| 94 | ||
| @@ 36-97 (lines=62) @@ | ||
| 33 | * @link https://github.com/techdivision/import |
|
| 34 | * @link http://www.techdivision.com |
|
| 35 | */ |
|
| 36 | class EavAttributeOptionValueLoader implements LoaderInterface |
|
| 37 | { |
|
| 38 | ||
| 39 | /** |
|
| 40 | * The attribute option values. |
|
| 41 | * |
|
| 42 | * @var array |
|
| 43 | */ |
|
| 44 | protected $eavAttributeOptionValues = array(); |
|
| 45 | ||
| 46 | /** |
|
| 47 | * Construct that initializes the iterator with the import processor instance. |
|
| 48 | * |
|
| 49 | * @param \TechDivision\Import\Services\ImportProcessorInterface $importProcessor The import processor instance |
|
| 50 | */ |
|
| 51 | public function __construct(ImportProcessorInterface $importProcessor) |
|
| 52 | { |
|
| 53 | ||
| 54 | // load the entity types |
|
| 55 | $entityTypes = $importProcessor->getEavEntityTypes(); |
|
| 56 | ||
| 57 | // prepare the array with the attribute sets |
|
| 58 | foreach ($entityTypes as $entityType) { |
|
| 59 | // prepare the array with the attribute sets |
|
| 60 | foreach ($importProcessor->getEavAttributeOptionValuesByEntityTypeIdAndStoreId($entityType[MemberNames::ENTITY_TYPE_ID], 0) as $eavAttributeOptionValue) { |
|
| 61 | $this->eavAttributeOptionValues[$entityType[MemberNames::ENTITY_TYPE_CODE]][$eavAttributeOptionValue[MemberNames::ATTRIBUTE_CODE]][] = $eavAttributeOptionValue[MemberNames::VALUE]; |
|
| 62 | } |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * Loads and returns data the custom validation data. |
|
| 68 | * |
|
| 69 | * @param \TechDivision\Import\Configuration\ParamsConfigurationInterface $configuration The configuration instance to load the validations from |
|
| 70 | * |
|
| 71 | * @return \ArrayAccess The array with the data |
|
| 72 | */ |
|
| 73 | public function load(SubjectConfigurationInterface $configuration = null) |
|
| 74 | { |
|
| 75 | ||
| 76 | // load the entity type code from the passed subject configuration |
|
| 77 | $entityTypeCode = $configuration->getExecutionContext()->getEntityTypeCode(); |
|
| 78 | ||
| 79 | // return the available attribute option values for the entity type |
|
| 80 | if (isset($this->eavAttributeOptionValues[$entityTypeCode])) { |
|
| 81 | return $this->eavAttributeOptionValues[$entityTypeCode]; |
|
| 82 | } |
|
| 83 | ||
| 84 | // return an empty array otherwise |
|
| 85 | return array(); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * Return's the import processor instance. |
|
| 90 | * |
|
| 91 | * @return \TechDivision\Import\Services\ImportProcessorInterface The processor instance |
|
| 92 | */ |
|
| 93 | protected function getImportProcessor() |
|
| 94 | { |
|
| 95 | return $this->importProcessor; |
|
| 96 | } |
|
| 97 | } |
|
| 98 | ||