Code Duplication    Length = 19-24 lines in 2 locations

src/Observers/PreLoadAttributeOptionIdObserver.php 1 location

@@ 71-94 (lines=24) @@
68
     *
69
     * @return array The processed row
70
     */
71
    protected function process()
72
    {
73
74
        // load the store value and the attribute code
75
        $value = $this->getValue(ColumnKeys::ADMIN_STORE_VALUE);
76
        $attributeCode = $this->getValue(ColumnKeys::ATTRIBUTE_CODE);
77
78
        // query whether or not, we've found a new attribute code => means we've found a new EAV attribute
79
        if ($this->hasBeenProcessed($attributeCode, $value)) {
80
            return;
81
        }
82
83
        // load the entity type ID for the value from the system configuration
84
        $entityTypeId = $this->getEntityTypeId();
85
86
        // load the ID of the admin store
87
        $storeId = $this->getStoreId(StoreViewCodes::ADMIN);
88
89
        // load the EAV attribute option with the passed value
90
        $attributeOption = $this->loadAttributeOptionByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value);
91
92
        // preserve the attribute ID for the passed EAV attribute option
93
        $this->preLoadOptionId($attributeOption);
94
    }
95
96
    /**
97
     * Queries whether or not the option with the passed code/value has already been processed.

src/Observers/AttributeOptionUpdateObserver.php 1 location

@@ 69-87 (lines=19) @@
66
     *
67
     * @return array The initialized EAV attribute option
68
     */
69
    protected function initializeAttribute(array $attr)
70
    {
71
72
        // load the entity type ID for the value from the system configuration
73
        $entityTypeId = $this->getEntityTypeId();
74
75
        // initialize the data to load the EAV attribute option
76
        $value = $this->getValue(ColumnKeys::VALUE);
77
        $storeId = $this->getRowStoreId(StoreViewCodes::ADMIN);
78
        $attributeCode = $this->getValue(ColumnKeys::ATTRIBUTE_CODE);
79
80
        // try to load the EAV attribute option
81
        if ($attributeOption = $this->loadAttributeOptionByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value)) {
82
            return $this->mergeEntity($attributeOption, $attr);
83
        }
84
85
        // simply return the attributes
86
        return $attr;
87
    }
88
89
    /**
90
     * Load's and return's the EAV attribute option with the passed entity type ID, code, store ID and value.