schemaSetup = $schemaSetup; $this->attributeRepository = $attributeRepository; } public static function getDependencies(): array { return [CreateAttributes::class]; } public function getAliases(): array { return []; } public function apply(): self { $this->moveProductAttributeData(); $this->moveCategoryAttributeData(); return $this; } private function moveProductAttributeData(): void { $attribute = $this->attributeRepository->get(Product::ENTITY, self::HIDE_PRICE_CUSTOMER_GROUP_ATTR); $this->transferData( self::PRODUCT_ENTITY_VARCHAR_TABLE, self::PRODUCT_ENTITY_TEXT_TABLE, (int)$attribute->getAttributeId() ); } private function moveCategoryAttributeData(): void { $attribute = $this->attributeRepository->get(Category::ENTITY, self::HIDE_PRICE_CUSTOMER_GROUP_CAT_ATTR); $this->transferData( self::CATEGORY_ENTITY_VARCHAR_TABLE, self::CATEGORY_ENTITY_TEXT_TABLE, (int)$attribute->getAttributeId() ); } private function transferData(string $fromTableName, string $toTableName, int $attributeId): void { $fromTable = $this->schemaSetup->getTable($fromTableName); $toTable = $this->schemaSetup->getTable($toTableName); $connection = $this->schemaSetup->getConnection(); $select = $connection->select() ->from($fromTable) ->where('attribute_id = ?', $attributeId); $attributeValues = $connection->fetchAll($select); foreach ($attributeValues as $value) { unset($value['value_id']); $connection->insert($toTable, $value); } } }