Completed
Push — 1.9 ( d8eb28...5c3e2e )
by
unknown
61:52 queued 29s
created

DefaultMagentoImportStrategy::findExistingEntity()   D

Complexity

Conditions 9
Paths 12

Size

Total Lines 38
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 3 Features 0
Metric Value
c 4
b 3
f 0
dl 0
loc 38
rs 4.9091
cc 9
eloc 22
nc 12
nop 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A DefaultMagentoImportStrategy::findEntityByIdentityValues() 0 8 2
A DefaultMagentoImportStrategy::getPropertyAccessor() 0 7 2
1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\ImportExport\Strategy;
4
5
use Symfony\Component\PropertyAccess\PropertyAccess;
6
use Symfony\Component\PropertyAccess\PropertyAccessor;
7
8
use Oro\Bundle\ImportExportBundle\Strategy\Import\ConfigurableAddOrReplaceStrategy;
9
10
class DefaultMagentoImportStrategy extends ConfigurableAddOrReplaceStrategy
11
{
12
    /** @var PropertyAccessor */
13
    protected $propertyAccessor;
14
15
    /**
16
     * {@inheritdoc}
17
     */
18
    protected function updateContextCounters($entity)
19
    {
20
        // increment context counter
21
        $identifier = $this->databaseHelper->getIdentifier($entity);
22
        if ($identifier) {
23
            $this->context->incrementUpdateCount();
24
        } else {
25
            $this->context->incrementAddCount();
26
        }
27
28
        return $entity;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function findEntityByIdentityValues($entityName, array $identityValues)
35
    {
36
        if (is_a($entityName, 'OroCRM\Bundle\MagentoBundle\Entity\IntegrationAwareInterface', true)) {
37
            $identityValues['channel'] = $this->context->getOption('channel');
38
        }
39
40
        return parent::findEntityByIdentityValues($entityName, $identityValues);
41
    }
42
43
    /**
44
     * @return PropertyAccessor
45
     */
46
    protected function getPropertyAccessor()
47
    {
48
        if (!$this->propertyAccessor) {
49
            $this->propertyAccessor = PropertyAccess::createPropertyAccessor();
50
        }
51
        return $this->propertyAccessor;
52
    }
53
}
54