setup = $setup; } public function apply(): self { $this->updateReplaceLinkSetting(); $this->updateAddToCartSetting(); return $this; } private function updateAddToCartSetting(): void { $connection = $this->setup->getConnection(); $tableName = $this->setup->getTable(self::TABLE_CORE_CONFIG_DATA); $select = $this->setup->getConnection()->select() ->from($tableName, ['path', 'value', 'scope', 'scope_id', 'config_id']) ->where('path = ?', self::ADD_TO_CART_SETTING_PATH); $replaceLinks = $connection->fetchAll($select); foreach ($replaceLinks as $replaceLink) { if (isset($replaceLink['value'])) { if (strpos($replaceLink['value'], self::FORM_SELECTOR) !== false) { $value = str_replace(self::FORM_SELECTOR, self::NEW_FORM_SELECTOR, $replaceLink['value']); $connection->update( $tableName, ['value' => $value], ['config_id = ?' => $replaceLink['config_id']] ); } } } } private function updateReplaceLinkSetting(): void { $connection = $this->setup->getConnection(); $tableName = $this->setup->getTable(self::TABLE_CORE_CONFIG_DATA); $select = $this->setup->getConnection()->select() ->from($tableName, ['path', 'value', 'scope', 'scope_id']) ->where('path = ?', self::REPLACE_LINK_SETTING_PATH); $replaceLinks = $connection->fetchAll($select); foreach ($replaceLinks as $replaceLink) { if (isset($replaceLink['value'])) { if ($replaceLink['value'] === 'AmastyHidePricePopup') { $updateData[] = [ 'value' => ReplaceButton::HIDE_PRICE_POPUP, 'path' => self::REPLACE_WITH_SETTING_PATH, 'scope' => $replaceLink['scope'], 'scope_id' => $replaceLink['scope_id'] ]; } else { $updateData[] = [ 'value' => ReplaceButton::REDIRECT_URL, 'path' => self::REPLACE_WITH_SETTING_PATH, 'scope' => $replaceLink['scope'], 'scope_id' => $replaceLink['scope_id'] ]; $updateData[] = [ 'value' => $replaceLink['value'], 'path' => self::REDIRECT_LINK_SETTING_PATH, 'scope' => $replaceLink['scope'], 'scope_id' => $replaceLink['scope_id'] ]; } } } if (!empty($updateData)) { $connection->insertOnDuplicate( $tableName, $updateData ); } } public function getAliases(): array { return []; } public static function getDependencies(): array { return []; } }