From 5d887781141c66460d3e3acd30a562fec4930f57 Mon Sep 17 00:00:00 2001 From: Thomas Da Silva Date: Mon, 13 May 2024 15:47:08 +0200 Subject: [PATCH 1/3] remove useless delay field --- Config/module.xml | 2 +- Controller/GuaranteedOpinionConfigController.php | 1 - Form/ConfigurationForm.php | 9 --------- GuaranteedOpinion.php | 1 - I18n/fr_FR.php | 1 - templates/backOffice/default/module_configuration.html | 1 - 6 files changed, 1 insertion(+), 14 deletions(-) diff --git a/Config/module.xml b/Config/module.xml index c171315..00cb447 100644 --- a/Config/module.xml +++ b/Config/module.xml @@ -13,7 +13,7 @@ en_US fr_FR - 1.0.14 + 1.0.15 Chabreuil Antoine diff --git a/Controller/GuaranteedOpinionConfigController.php b/Controller/GuaranteedOpinionConfigController.php index d64f30a..6416770 100644 --- a/Controller/GuaranteedOpinionConfigController.php +++ b/Controller/GuaranteedOpinionConfigController.php @@ -27,7 +27,6 @@ public function saveConfiguration(ParserContext $parserContext) : RedirectRespon GuaranteedOpinion::setConfigValue(GuaranteedOpinion::SHOW_RATING_URL_CONFIG_KEY, $data["show_rating_url"]); GuaranteedOpinion::setConfigValue(GuaranteedOpinion::STATUS_TO_EXPORT_CONFIG_KEY, implode(',', $data["status_to_export"])); - GuaranteedOpinion::setConfigValue(GuaranteedOpinion::EMAIL_DELAY_CONFIG_KEY, $data["email_delay"]); GuaranteedOpinion::setConfigValue(GuaranteedOpinion::SITE_REVIEW_HOOK_DISPLAY_CONFIG_KEY, $data["site_review_hook_display"]); GuaranteedOpinion::setConfigValue(GuaranteedOpinion::SITE_REVIEW_DISPLAY_CONFIG_KEY, (bool)$data["site_review_display"]); diff --git a/Form/ConfigurationForm.php b/Form/ConfigurationForm.php index d8418dd..de2ae2a 100644 --- a/Form/ConfigurationForm.php +++ b/Form/ConfigurationForm.php @@ -65,15 +65,6 @@ protected function buildForm(): void ), "data" => GuaranteedOpinion::getConfigValue(GuaranteedOpinion::API_ORDER_CONFIG_KEY) )) - ->add( - 'email_delay', - TextType::class, - [ - "data" => GuaranteedOpinion::getConfigValue(GuaranteedOpinion::EMAIL_DELAY_CONFIG_KEY, 10), - "label"=>$translator?->trans("Reviews email delay (in days):", array(), GuaranteedOpinion::DOMAIN_NAME), - "required" => false - ] - ) ->add( 'show_rating_url', TextType::class, diff --git a/GuaranteedOpinion.php b/GuaranteedOpinion.php index fafbd00..e95088f 100644 --- a/GuaranteedOpinion.php +++ b/GuaranteedOpinion.php @@ -18,7 +18,6 @@ class GuaranteedOpinion extends BaseModule public const API_ORDER_CONFIG_KEY = "guaranteedopinion.api.order"; public const STATUS_TO_EXPORT_CONFIG_KEY = "guaranteedopinion.status_to_export"; - public const EMAIL_DELAY_CONFIG_KEY = "guaranteedopinion.email_delay"; public const SHOW_RATING_URL_CONFIG_KEY = "guaranteedopinion.show_rating_url"; diff --git a/I18n/fr_FR.php b/I18n/fr_FR.php index e60fc4f..a49ba98 100644 --- a/I18n/fr_FR.php +++ b/I18n/fr_FR.php @@ -5,7 +5,6 @@ 'Api key review' => 'Clé API publique des avis', 'Order status to export' => 'Statut des commandes à envoyer', 'Product review hook display' => 'Lien du hook des avis des produits', - 'Reviews email delay (in days):' => 'Delai de l\'envoi du mail (en jours)', 'Show all opinions url' => 'Url des avis vérifiés du sites', 'Show product review' => 'Montrer les avis des produits', 'Show product review tab' => 'Montrer le tableau des avis des produits', diff --git a/templates/backOffice/default/module_configuration.html b/templates/backOffice/default/module_configuration.html index 420151e..5a08b87 100644 --- a/templates/backOffice/default/module_configuration.html +++ b/templates/backOffice/default/module_configuration.html @@ -42,7 +42,6 @@

{intl l="Guaranteed Opinion Order access" d
- {render_form_field form=$form field="email_delay"} {render_form_field form=$form field="status_to_export"}
From 6962beb2fb2836ac6c8e4a175cb897cba1cc3328 Mon Sep 17 00:00:00 2001 From: Thomas Da Silva Date: Mon, 13 May 2024 15:47:51 +0200 Subject: [PATCH 2/3] Fix Query productUrl --- Model/GuaranteedOpinionOrderQueueQuery.php | 4 +++- Service/OrderService.php | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Model/GuaranteedOpinionOrderQueueQuery.php b/Model/GuaranteedOpinionOrderQueueQuery.php index 8858e57..7ae5500 100644 --- a/Model/GuaranteedOpinionOrderQueueQuery.php +++ b/Model/GuaranteedOpinionOrderQueueQuery.php @@ -30,11 +30,13 @@ public static function getCategoryByProductSaleElements(ProductSaleElements $pro ->findOne(); } - public static function getProductUrl(int $id): RewritingUrl + public static function getProductUrl(int $id, string $locale = 'fr_FR'): RewritingUrl { return RewritingUrlQuery::create() ->filterByView('product') ->filterByViewId($id) + ->filterByViewLocale($locale) + ->filterByRedirected() ->findOne(); } } diff --git a/Service/OrderService.php b/Service/OrderService.php index 7b1cefa..56f1158 100644 --- a/Service/OrderService.php +++ b/Service/OrderService.php @@ -76,22 +76,22 @@ private function productToJsonObject(OrderProduct $orderProduct): array } $category = GuaranteedOpinionOrderQueueQuery::getCategoryByProductSaleElements($pse); - $productReviewEvent = new ProductReviewEvent($pse?->getProduct()); + $productReviewEvent = new ProductReviewEvent($pse->getProduct()); $this->eventDispatcher->dispatch($productReviewEvent, GuaranteedOpinionEvents::SEND_ORDER_PRODUCT_EVENT); return [ 'id' => $productReviewEvent->getGuaranteedOpinionProductId(), - 'name' => $pse?->getProduct()->getRef(), + 'name' => $pse->getProduct()->getRef(), 'category_id' => $category->getId(), 'category_name' => $category->getTitle(), 'qty' => $orderProduct->getQuantity(), 'unit_price' => $orderProduct->getPrice(), 'mpn' => null, - 'ean13' => $pse?->getEanCode(), + 'ean13' => $pse->getEanCode(), 'sku' => null, 'upc' => null, 'url' => URL::getInstance()->absoluteUrl('') . - GuaranteedOpinionOrderQueueQuery::getProductUrl($pse?->getProductId())->getUrl(), + GuaranteedOpinionOrderQueueQuery::getProductUrl($pse->getProductId())->getUrl(), ]; } From 9b8418dac186c7d980b323d9061e73165f122734 Mon Sep 17 00:00:00 2001 From: Thomas Da Silva Date: Mon, 13 May 2024 16:15:00 +0200 Subject: [PATCH 3/3] Add locale option --- Command/SendOrderCommand.php | 7 +++++-- Service/OrderService.php | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Command/SendOrderCommand.php b/Command/SendOrderCommand.php index b0fc979..ab24f25 100644 --- a/Command/SendOrderCommand.php +++ b/Command/SendOrderCommand.php @@ -6,6 +6,7 @@ use GuaranteedOpinion\Api\GuaranteedOpinionClient; use GuaranteedOpinion\Service\OrderService; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Thelia\Command\ContainerAwareCommand; @@ -22,7 +23,9 @@ public function configure(): void { $this ->setName('module:GuaranteedOpinion:SendOrder') - ->setDescription('Send orders to API Avis-Garantis'); + ->setDescription('Send orders to API Avis-Garantis') + ->addOption('locale', 'l', InputOption::VALUE_OPTIONAL, 'locale', 'fr_FR') + ; } public function execute(InputInterface $input, OutputInterface $output): int @@ -30,7 +33,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $this->initRequest(); try { - $order = $this->orderService->prepareOrderRequest(); + $order = $this->orderService->prepareOrderRequest($input->getOption('locale')); $response = $this->client->sendOrder($order); diff --git a/Service/OrderService.php b/Service/OrderService.php index 56f1158..d0edafc 100644 --- a/Service/OrderService.php +++ b/Service/OrderService.php @@ -25,14 +25,14 @@ public function __construct( /** * @throws JsonException|RuntimeException|PropelException */ - public function prepareOrderRequest(): string + public function prepareOrderRequest(string $locale): string { $jsonOrder = []; $guaranteedOpinionOrders = GuaranteedOpinionOrderQueueQuery::create()->filterByTreatedAt(null)->findByStatus(0); foreach ($guaranteedOpinionOrders as $guaranteedOpinionOrder) { - $jsonOrder[] = $this->orderToJsonObject($guaranteedOpinionOrder); + $jsonOrder[] = $this->orderToJsonObject($guaranteedOpinionOrder, $locale); } if (empty($jsonOrder)) { @@ -45,14 +45,14 @@ public function prepareOrderRequest(): string /** * @throws PropelException */ - private function orderToJsonObject(GuaranteedOpinionOrderQueue $guaranteedOpinionOrder): array + private function orderToJsonObject(GuaranteedOpinionOrderQueue $guaranteedOpinionOrder, string $locale): array { $order = OrderQuery::create()->findOneById($guaranteedOpinionOrder->getOrderId()); $jsonProduct = []; foreach ($order?->getOrderProducts() as $orderProduct) { - $jsonProduct[] = $this->productToJsonObject($orderProduct); + $jsonProduct[] = $this->productToJsonObject($orderProduct, $locale); } return [ @@ -69,7 +69,7 @@ private function orderToJsonObject(GuaranteedOpinionOrderQueue $guaranteedOpinio /** * @throws PropelException */ - private function productToJsonObject(OrderProduct $orderProduct): array + private function productToJsonObject(OrderProduct $orderProduct, string $locale): array { if (null === $pse = ProductSaleElementsQuery::create()->findOneById($orderProduct->getProductSaleElementsId())) { return []; @@ -91,7 +91,7 @@ private function productToJsonObject(OrderProduct $orderProduct): array 'sku' => null, 'upc' => null, 'url' => URL::getInstance()->absoluteUrl('') . - GuaranteedOpinionOrderQueueQuery::getProductUrl($pse->getProductId())->getUrl(), + GuaranteedOpinionOrderQueueQuery::getProductUrl($pse->getProductId(), $locale)->getUrl(), ]; }