From 31a7196d38e866347d2bcd518948a180bcaa97d5 Mon Sep 17 00:00:00 2001 From: Dakeyama Date: Sun, 31 Jan 2021 00:08:05 +0900 Subject: [PATCH 01/12] =?UTF-8?q?=E5=95=86=E5=93=81=E4=B8=80=E8=A6=A7?= =?UTF-8?q?=E3=83=BB=E7=99=BB=E9=8C=B2=E7=94=BB=E9=9D=A2=E3=81=AE=E8=A6=8F?= =?UTF-8?q?=E6=A0=BC=E6=83=85=E5=A0=B1=E4=B8=A6=E3=81=B3=E9=A0=86=E3=82=92?= =?UTF-8?q?sort=5Fno=E3=81=A7=E5=88=B6=E5=BE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Controller/Admin/Product/ProductController.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Eccube/Controller/Admin/Product/ProductController.php b/src/Eccube/Controller/Admin/Product/ProductController.php index f8ae3d3b731..cc869330d60 100644 --- a/src/Eccube/Controller/Admin/Product/ProductController.php +++ b/src/Eccube/Controller/Admin/Product/ProductController.php @@ -274,7 +274,7 @@ public function index(Request $request, $page_no = null, Paginator $paginator) /** * @Route("/%eccube_admin_route%/product/classes/{id}/load", name="admin_product_classes_load", methods={"GET"}, requirements={"id" = "\d+"}) * @Template("@admin/Product/product_class_popup.twig") - * @ParamConverter("Product") + * @ParamConverter("Product", options={"repository_method":"findWithSortedClassCategories"}) */ public function loadProductClasses(Request $request, Product $Product) { @@ -291,9 +291,7 @@ public function loadProductClasses(Request $request, Product $Product) if ($Product->hasProductClass()) { $class = $Product->getProductClasses(); foreach ($class as $item) { - if ($item['visible']) { - $data[] = $item; - } + $data[] = $item; } } @@ -373,7 +371,7 @@ public function edit(Request $request, $id = null, RouterInterface $router, Cach $ProductClass->setProductStock($ProductStock); $ProductStock->setProductClass($ProductClass); } else { - $Product = $this->productRepository->find($id); + $Product = $this->productRepository->findWithSortedClassCategories($id); $ProductClass = null; $ProductStock = null; if (!$Product) { From 0a83160aca2ab9e24173b904bc227bac8fb7b4d7 Mon Sep 17 00:00:00 2001 From: hideki_okajima Date: Fri, 26 Mar 2021 14:33:42 +0900 Subject: [PATCH 02/12] =?UTF-8?q?Generator=20=E3=81=A7=20Product=20?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E6=99=82=E3=81=AB=20ProductTag=20=E3=82=82?= =?UTF-8?q?=E3=82=BB=E3=83=83=E3=83=88=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packages/codeception/generator.yaml | 3 +- app/config/eccube/packages/dev/generator.yaml | 1 + .../eccube/packages/test/generator.yaml | 3 +- tests/Eccube/Tests/Fixture/Generator.php | 32 +++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/app/config/eccube/packages/codeception/generator.yaml b/app/config/eccube/packages/codeception/generator.yaml index 8995e4975cd..c48bd1bf6df 100644 --- a/app/config/eccube/packages/codeception/generator.yaml +++ b/app/config/eccube/packages/codeception/generator.yaml @@ -13,9 +13,10 @@ services: - '@Eccube\Repository\PaymentRepository' - '@Eccube\Repository\PageRepository' - '@Eccube\Repository\Master\PrefRepository' + - '@Eccube\Repository\TagRepository' - '@Eccube\Repository\TaxRuleRepository' - '@eccube.purchase.flow.order' - '@session' - 'ja_JP' lazy: true - public: true # Codeception対応 \ No newline at end of file + public: true # Codeception対応 diff --git a/app/config/eccube/packages/dev/generator.yaml b/app/config/eccube/packages/dev/generator.yaml index f44ff6b9ef2..41493bade30 100644 --- a/app/config/eccube/packages/dev/generator.yaml +++ b/app/config/eccube/packages/dev/generator.yaml @@ -13,6 +13,7 @@ services: - '@Eccube\Repository\PaymentRepository' - '@Eccube\Repository\PageRepository' - '@Eccube\Repository\Master\PrefRepository' + - '@Eccube\Repository\TagRepository' - '@Eccube\Repository\TaxRuleRepository' - '@eccube.purchase.flow.order' - '@session' diff --git a/app/config/eccube/packages/test/generator.yaml b/app/config/eccube/packages/test/generator.yaml index 8995e4975cd..c48bd1bf6df 100644 --- a/app/config/eccube/packages/test/generator.yaml +++ b/app/config/eccube/packages/test/generator.yaml @@ -13,9 +13,10 @@ services: - '@Eccube\Repository\PaymentRepository' - '@Eccube\Repository\PageRepository' - '@Eccube\Repository\Master\PrefRepository' + - '@Eccube\Repository\TagRepository' - '@Eccube\Repository\TaxRuleRepository' - '@eccube.purchase.flow.order' - '@session' - 'ja_JP' lazy: true - public: true # Codeception対応 \ No newline at end of file + public: true # Codeception対応 diff --git a/tests/Eccube/Tests/Fixture/Generator.php b/tests/Eccube/Tests/Fixture/Generator.php index 19b05c61acb..89cf3119f2c 100644 --- a/tests/Eccube/Tests/Fixture/Generator.php +++ b/tests/Eccube/Tests/Fixture/Generator.php @@ -35,6 +35,7 @@ use Eccube\Entity\ProductClass; use Eccube\Entity\ProductImage; use Eccube\Entity\ProductStock; +use Eccube\Entity\ProductTag; use Eccube\Entity\Shipping; use Eccube\Repository\CategoryRepository; use Eccube\Repository\ClassCategoryRepository; @@ -46,6 +47,7 @@ use Eccube\Repository\MemberRepository; use Eccube\Repository\PageRepository; use Eccube\Repository\PaymentRepository; +use Eccube\Repository\TagRepository; use Eccube\Repository\TaxRuleRepository; use Eccube\Security\Core\Encoder\PasswordEncoder; use Eccube\Service\PurchaseFlow\PurchaseContext; @@ -78,6 +80,11 @@ class Generator */ protected $memberRepository; + /** + * @var CategoryRepository + */ + private $categoryRepository; + /** * @var CustomerRepository */ @@ -108,6 +115,11 @@ class Generator */ protected $paymentRepository; + /** + * @var TagRepository + */ + private $tagRepository; + /** * @var TaxRuleRepository */ @@ -123,6 +135,11 @@ class Generator */ protected $PrefRepository; + /** + * @var PrefRepository + */ + private $prefRepository; + /** * @var SessionInterface */ @@ -146,6 +163,7 @@ public function __construct( PaymentRepository $paymentRepository, PageRepository $pageRepository, PrefRepository $prefRepository, + TagRepository $tagRepository, TaxRuleRepository $taxRuleRepository, PurchaseFlow $orderPurchaseFlow, SessionInterface $session, @@ -164,6 +182,7 @@ public function __construct( $this->paymentRepository = $paymentRepository; $this->pageRepository = $pageRepository; $this->prefRepository = $prefRepository; + $this->tagRepository = $tagRepository; $this->taxRuleRepository = $taxRuleRepository; $this->orderPurchaseFlow = $orderPurchaseFlow; $this->session = $session; @@ -518,6 +537,19 @@ public function createProduct($product_name = null, $product_class_num = 3, $ima $Product->addProductCategory($ProductCategory); } + $Tags = $this->tagRepository->findAll(); + foreach ($Tags as $Tag) { + $ProductTag = new ProductTag(); + $ProductTag + ->setProduct($Product) + ->setTag($Tag) + ->setCreateDate(new \DateTime()) // FIXME + ->setCreator($Member); + $this->entityManager->persist($ProductTag); + $this->entityManager->flush($ProductTag); + $Product->addProductTag($ProductTag); + } + $this->entityManager->flush($Product); return $Product; From 45ab00edc7a0001385777200f17523853618fdca Mon Sep 17 00:00:00 2001 From: hideki_okajima Date: Fri, 26 Mar 2021 15:45:38 +0900 Subject: [PATCH 03/12] =?UTF-8?q?Product=20=E5=89=8A=E9=99=A4=E3=81=A7=20P?= =?UTF-8?q?roductTag=20=E3=82=82=E5=89=8A=E9=99=A4=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20DB=20=E3=81=AE=E3=82=B9?= =?UTF-8?q?=E3=82=AD=E3=83=BC=E3=83=9E=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tests/Doctrine/ORM/Tools/PaginationTest.php | 13 ++++++++++--- ...uctRepositoryGetQueryBuilderBySearchDataTest.php | 1 + tests/Eccube/Tests/Web/CartValidationTest.php | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/Eccube/Tests/Doctrine/ORM/Tools/PaginationTest.php b/tests/Eccube/Tests/Doctrine/ORM/Tools/PaginationTest.php index c389ef82f3c..c821f246c77 100644 --- a/tests/Eccube/Tests/Doctrine/ORM/Tools/PaginationTest.php +++ b/tests/Eccube/Tests/Doctrine/ORM/Tools/PaginationTest.php @@ -17,6 +17,7 @@ use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Mapping as ORM; use Eccube\Entity\ProductTag; +use Eccube\Entity\Tag; use Eccube\Tests\EccubeTestCase; use Eccube\Repository\ProductRepository; use Knp\Component\Pager\PaginatorInterface; @@ -230,7 +231,13 @@ public function testSortWithJoinPluginEntity() public function testWhereWithJoinEntity() { // `新商品`のTagが登録されたProductを生成 - $Tag = $this->tagRepository->find(1); + $MaxTag = $this->tagRepository->findOneBy([], ['sort_no' => 'DESC']); + $Tag = new Tag(); + $Tag->setName('join-test'); + $Tag->setSortNo($MaxTag->getSortNo() + 1); + $this->entityManager->persist($Tag); + $this->entityManager->flush(); + $Member = $this->memberRepository->find(2); $Product = $this->productRepository->find(reset($this->expectedIds)); @@ -241,7 +248,7 @@ public function testWhereWithJoinEntity() $Product->addProductTag($ProductTag); $this->entityManager->persist($ProductTag); - $this->entityManager->flush([$Product, $ProductTag]); + $this->entityManager->flush(); $qb = $this->productRepository->getQueryBuilderBySearchData([]); @@ -272,7 +279,7 @@ public function testWhereWithJoinEntity() $this->expected = $expectedIds; $this->actual = $actualIds; // tagが登録されたProductは1件のみ. - $this->assertTrue(count($this->actual) === 1); + $this->assertSame(count($this->actual), 1); $this->verify(); } diff --git a/tests/Eccube/Tests/Repository/ProductRepositoryGetQueryBuilderBySearchDataTest.php b/tests/Eccube/Tests/Repository/ProductRepositoryGetQueryBuilderBySearchDataTest.php index 467f3585100..06c2bf8708b 100644 --- a/tests/Eccube/Tests/Repository/ProductRepositoryGetQueryBuilderBySearchDataTest.php +++ b/tests/Eccube/Tests/Repository/ProductRepositoryGetQueryBuilderBySearchDataTest.php @@ -354,6 +354,7 @@ public function test300ProductsList() 'dtb_product_stock', 'dtb_product_class', 'dtb_product_category', + 'dtb_product_tag', 'dtb_product', ]; $this->deleteAllRows($tables); diff --git a/tests/Eccube/Tests/Web/CartValidationTest.php b/tests/Eccube/Tests/Web/CartValidationTest.php index 838eeea39f2..1249b394048 100644 --- a/tests/Eccube/Tests/Web/CartValidationTest.php +++ b/tests/Eccube/Tests/Web/CartValidationTest.php @@ -2727,6 +2727,7 @@ protected function deleteAllProduct() 'dtb_product_class', 'dtb_product_image', 'dtb_product_category', + 'dtb_product_tag', 'dtb_customer_favorite_product', 'dtb_product', ]); From d4a9df7cda0028aa225c490f40afd6f3bb0d9c27 Mon Sep 17 00:00:00 2001 From: hideki_okajima Date: Fri, 26 Mar 2021 16:15:50 +0900 Subject: [PATCH 04/12] =?UTF-8?q?flush()=20=E3=81=AE=E5=BC=95=E6=95=B0?= =?UTF-8?q?=E3=81=AF=E9=9D=9E=E6=8E=A8=E5=A5=A8=E3=81=AE=E3=81=9F=E3=82=81?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Eccube/Tests/Fixture/Generator.php | 52 ++++++++++++------------ 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/tests/Eccube/Tests/Fixture/Generator.php b/tests/Eccube/Tests/Fixture/Generator.php index 89cf3119f2c..f35ae79f3e9 100644 --- a/tests/Eccube/Tests/Fixture/Generator.php +++ b/tests/Eccube/Tests/Fixture/Generator.php @@ -269,9 +269,7 @@ public function createCustomer($email = null) ->setUpdateDate(new \DateTime()) ->setPoint($faker->randomNumber(5)); $this->entityManager->persist($Customer); - $this->entityManager->flush($Customer); - - $this->entityManager->flush($Customer); + $this->entityManager->flush(); return $Customer; } @@ -314,7 +312,7 @@ public function createCustomerAddress(Customer $Customer, $is_nonmember = false) $this->session->set($sessionCustomerAddressKey, serialize($customerAddresses)); } else { $this->entityManager->persist($CustomerAddress); - $this->entityManager->flush($CustomerAddress); + $this->entityManager->flush(); } return $CustomerAddress; @@ -399,7 +397,7 @@ public function createProduct($product_name = null, $product_class_num = 3, $ima $Product->extendedParameter = 'aaaa'; $this->entityManager->persist($Product); - $this->entityManager->flush($Product); + $this->entityManager->flush(); $faker2 = Faker::create($this->locale); $faker2->addProvider(new ImagesGeneratorProvider($faker2)); @@ -430,7 +428,7 @@ public function createProduct($product_name = null, $product_class_num = 3, $ima ->setCreateDate(new \DateTime()) // FIXME ->setProduct($Product); $this->entityManager->persist($ProductImage); - $this->entityManager->flush($ProductImage); + $this->entityManager->flush(); $Product->addProductImage($ProductImage); } @@ -455,7 +453,7 @@ public function createProduct($product_name = null, $product_class_num = 3, $ima ->setCreator($Member) ->setStock($faker->numberBetween(100, 999)); $this->entityManager->persist($ProductStock); - $this->entityManager->flush($ProductStock); + $this->entityManager->flush(); $ProductClass = new ProductClass(); $ProductClass ->setCode($faker->word) @@ -479,11 +477,11 @@ public function createProduct($product_name = null, $product_class_num = 3, $ima } $this->entityManager->persist($ProductClass); - $this->entityManager->flush($ProductClass); + $this->entityManager->flush(); $ProductStock->setProductClass($ProductClass); $ProductStock->setProductClassId($ProductClass->getId()); - $this->entityManager->flush($ProductStock); + $this->entityManager->flush(); $Product->addProductClass($ProductClass); } @@ -495,7 +493,7 @@ public function createProduct($product_name = null, $product_class_num = 3, $ima ->setCreator($Member) ->setStock($faker->randomNumber(3)); $this->entityManager->persist($ProductStock); - $this->entityManager->flush($ProductStock); + $this->entityManager->flush(); $ProductClass = new ProductClass(); if ($product_class_num > 0) { $ProductClass->setVisible(false); @@ -516,11 +514,11 @@ public function createProduct($product_name = null, $product_class_num = 3, $ima ->setUpdateDate(new \DateTime()) ->setProduct($Product); $this->entityManager->persist($ProductClass); - $this->entityManager->flush($ProductClass); + $this->entityManager->flush(); $ProductStock->setProductClass($ProductClass); $ProductStock->setProductClassId($ProductClass->getId()); - $this->entityManager->flush($ProductStock); + $this->entityManager->flush(); $Product->addProductClass($ProductClass); @@ -533,7 +531,7 @@ public function createProduct($product_name = null, $product_class_num = 3, $ima ->setCategoryId($Category->getId()) ->setProductId($Product->getId()); $this->entityManager->persist($ProductCategory); - $this->entityManager->flush($ProductCategory); + $this->entityManager->flush(); $Product->addProductCategory($ProductCategory); } @@ -546,11 +544,11 @@ public function createProduct($product_name = null, $product_class_num = 3, $ima ->setCreateDate(new \DateTime()) // FIXME ->setCreator($Member); $this->entityManager->persist($ProductTag); - $this->entityManager->flush($ProductTag); + $this->entityManager->flush(); $Product->addProductTag($ProductTag); } - $this->entityManager->flush($Product); + $this->entityManager->flush(); return $Product; } @@ -593,7 +591,7 @@ public function createOrder(Customer $Customer, array $ProductClasses = [], Deli ; $this->entityManager->persist($Order); - $this->entityManager->flush($Order); + $this->entityManager->flush(); if (!is_object($Delivery)) { $Delivery = $this->createDelivery(); foreach ($Payments as $Payment) { @@ -605,9 +603,9 @@ public function createOrder(Customer $Customer, array $ProductClasses = [], Deli ->setPayment($Payment); $Payment->addPaymentOption($PaymentOption); $this->entityManager->persist($PaymentOption); - $this->entityManager->flush($PaymentOption); + $this->entityManager->flush(); } - $this->entityManager->flush($Payment); + $this->entityManager->flush(); } $DeliveryFee = $this->deliveryFeeRepository->findOneBy( [ @@ -629,7 +627,7 @@ public function createOrder(Customer $Customer, array $ProductClasses = [], Deli $Order->addShipping($Shipping); $this->entityManager->persist($Shipping); - $this->entityManager->flush($Shipping); + $this->entityManager->flush(); if (empty($ProductClasses)) { $Product = $this->createProduct(); @@ -749,7 +747,7 @@ public function createPayment(Delivery $Delivery, $method, $charge = 0, $rule_mi ->setCreator($Member) ->setVisible(true); $this->entityManager->persist($Payment); - $this->entityManager->flush($Payment); + $this->entityManager->flush(); $PaymentOption = new PaymentOption(); $PaymentOption @@ -760,10 +758,10 @@ public function createPayment(Delivery $Delivery, $method, $charge = 0, $rule_mi $Payment->addPaymentOption($PaymentOption); $this->entityManager->persist($PaymentOption); - $this->entityManager->flush($PaymentOption); + $this->entityManager->flush(); $Delivery->addPaymentOption($PaymentOption); - $this->entityManager->flush($Delivery); + $this->entityManager->flush(); return $Payment; } @@ -794,7 +792,7 @@ public function createDelivery($delivery_time_max_pattern = 5) ->setSaleType($SaleType) ->setVisible(true); $this->entityManager->persist($Delivery); - $this->entityManager->flush($Delivery); + $this->entityManager->flush(); $delivery_time_patten = $faker->numberBetween(0, $delivery_time_max_pattern); for ($i = 0; $i < $delivery_time_patten; $i++) { @@ -805,7 +803,7 @@ public function createDelivery($delivery_time_max_pattern = 5) ->setSortNo($i + 1) ->setVisible(true); $this->entityManager->persist($DeliveryTime); - $this->entityManager->flush($DeliveryTime); + $this->entityManager->flush(); $Delivery->addDeliveryTime($DeliveryTime); } @@ -818,11 +816,11 @@ public function createDelivery($delivery_time_max_pattern = 5) ->setPref($Pref) ->setDelivery($Delivery); $this->entityManager->persist($DeliveryFee); - $this->entityManager->flush($DeliveryFee); + $this->entityManager->flush(); $Delivery->addDeliveryFee($DeliveryFee); } - $this->entityManager->flush($Delivery); + $this->entityManager->flush(); return $Delivery; } @@ -848,7 +846,7 @@ public function createPage() ->setMetaTags('') ; $this->entityManager->persist($Page); - $this->entityManager->flush($Page); + $this->entityManager->flush(); return $Page; } From 76a77f0171e887ad7e3020a3062710ff8257dda0 Mon Sep 17 00:00:00 2001 From: Bell Date: Wed, 2 Jun 2021 13:52:22 +0900 Subject: [PATCH 05/12] =?UTF-8?q?=E9=87=8D=E8=A4=87=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9Fcompany=5Fname=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Form/Type/Admin/OrderType.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Eccube/Form/Type/Admin/OrderType.php b/src/Eccube/Form/Type/Admin/OrderType.php index 2bd20946b2a..09d27b43550 100644 --- a/src/Eccube/Form/Type/Admin/OrderType.php +++ b/src/Eccube/Form/Type/Admin/OrderType.php @@ -165,14 +165,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) new Assert\NotBlank(), ], ]) - ->add('company_name', TextType::class, [ - 'required' => false, - 'constraints' => [ - new Assert\Length([ - 'max' => $this->eccubeConfig['eccube_stext_len'], - ]), - ], - ]) ->add('message', TextareaType::class, [ 'required' => false, 'constraints' => [ From 9db51c2b27f0041900403751e0116fdcc2d772bc Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Mon, 6 Sep 2021 14:42:19 +0900 Subject: [PATCH 06/12] =?UTF-8?q?Revert=20"Revert=20"=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=20=E5=95=86=E5=93=81=E3=81=AE=E3=82=BF?= =?UTF-8?q?=E3=82=B0=E3=81=A7=E3=81=AE=E7=B5=9E=E3=82=8A=E8=BE=BC=E3=81=BF?= =?UTF-8?q?""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7233312d6c960bae66a873d3df38917b79a30a00. --- .../Form/Type/Admin/SearchProductType.php | 26 +++++++++- src/Eccube/Repository/ProductRepository.php | 8 +++ .../template/admin/Product/index.twig | 7 +++ .../AbstractProductRepositoryTestCase.php | 31 +++++++++++- ...ryGetQueryBuilderBySearchDataAdminTest.php | 49 +++++++++++++++++++ 5 files changed, 118 insertions(+), 3 deletions(-) diff --git a/src/Eccube/Form/Type/Admin/SearchProductType.php b/src/Eccube/Form/Type/Admin/SearchProductType.php index 72313c1656c..785542252b1 100644 --- a/src/Eccube/Form/Type/Admin/SearchProductType.php +++ b/src/Eccube/Form/Type/Admin/SearchProductType.php @@ -16,10 +16,13 @@ use Eccube\Entity\Category; use Eccube\Entity\Master\ProductStatus; use Eccube\Entity\ProductStock; +use Eccube\Entity\Tag; use Eccube\Form\Type\Master\CategoryType as MasterCategoryType; use Eccube\Form\Type\Master\ProductStatusType; use Eccube\Repository\CategoryRepository; use Eccube\Repository\Master\ProductStatusRepository; +use Eccube\Repository\TagRepository; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\DateTimeType; @@ -39,16 +42,26 @@ class SearchProductType extends AbstractType */ protected $categoryRepository; + /** + * @var TagRepository + */ + protected $tagRepository; + /** * SearchProductType constructor. * * @param ProductStatusRepository $productStatusRepository * @param CategoryRepository $categoryRepository + * @param TagRepository $tagRepository */ - public function __construct(ProductStatusRepository $productStatusRepository, CategoryRepository $categoryRepository) - { + public function __construct( + ProductStatusRepository $productStatusRepository, + CategoryRepository $categoryRepository, + TagRepository $tagRepository + ) { $this->productStatusRepository = $productStatusRepository; $this->categoryRepository = $categoryRepository; + $this->tagRepository = $tagRepository; } /** @@ -92,6 +105,15 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'expanded' => true, 'multiple' => true, ]) + ->add('tag_id', EntityType::class, [ + 'class' => Tag::class, + 'label' => 'admin.product.tag', + 'placeholder' => 'common.select__all_products', + 'choice_label' => 'name', + 'required' => false, + 'multiple' => false, + 'expanded' => false, + ]) ->add('create_date_start', DateType::class, [ 'label' => 'admin.common.create_date__start', 'required' => false, diff --git a/src/Eccube/Repository/ProductRepository.php b/src/Eccube/Repository/ProductRepository.php index 66056d35883..f4bde076a9a 100644 --- a/src/Eccube/Repository/ProductRepository.php +++ b/src/Eccube/Repository/ProductRepository.php @@ -303,6 +303,14 @@ public function getQueryBuilderBySearchDataForAdmin($searchData) } } + // tag + if (!empty($searchData['tag_id']) && $searchData['tag_id']) { + $qb + ->innerJoin('p.ProductTag', 'pt') + ->andWhere('pt.Tag = :tag_id') + ->setParameter('tag_id', $searchData['tag_id']); + } + // crate_date if (!empty($searchData['create_datetime_start']) && $searchData['create_datetime_start']) { $date = $searchData['create_datetime_start']; diff --git a/src/Eccube/Resource/template/admin/Product/index.twig b/src/Eccube/Resource/template/admin/Product/index.twig index 9128bb83200..48d8bdbdedd 100644 --- a/src/Eccube/Resource/template/admin/Product/index.twig +++ b/src/Eccube/Resource/template/admin/Product/index.twig @@ -229,6 +229,13 @@ file that was distributed with this source code.
+
+
+ + {{ form_widget(searchForm.tag_id) }} + {{ form_errors(searchForm.tag_id) }} +
+