Skip to content

Commit

Permalink
Merge branch '4.1' into feature/tag-search-front
Browse files Browse the repository at this point in the history
  • Loading branch information
matsuoshi authored Nov 26, 2021
2 parents 257a23d + 26db629 commit 284dd59
Show file tree
Hide file tree
Showing 17 changed files with 177 additions and 58 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.3-apache-stretch
FROM php:7.4-apache-bullseye

ENV APACHE_DOCUMENT_ROOT /var/www/html

Expand Down Expand Up @@ -32,7 +32,7 @@ RUN apt-get update \
;

RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/freetype2 --with-png-dir=/usr/include --with-jpeg-dir=/usr/include --with-webp-dir=/usr/include \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install -j$(nproc) zip gd mysqli pdo_mysql opcache intl pgsql pdo_pgsql \
;

Expand Down
3 changes: 2 additions & 1 deletion app/config/eccube/packages/codeception/generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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対応
public: true # Codeception対応
1 change: 1 addition & 0 deletions app/config/eccube/packages/dev/generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion app/config/eccube/packages/test/generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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対応
public: true # Codeception対応
15 changes: 8 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docker-compose.mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- mysql
environment:
DATABASE_URL: "mysql://dbuser:secret@mysql/eccubedb"
DATABASE_SERVER_VERSION: 10
DATABASE_SERVER_VERSION: 5.7

mysql:
image: mysql:5.7
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ services:
- postgres
environment:
DATABASE_URL: "postgres://dbuser:secret@postgres/eccubedb"
DATABASE_SERVER_VERSION: 10
DATABASE_SERVER_VERSION: 14

postgres:
image: postgres:10
image: postgres:14
environment:
POSTGRES_DB: eccubedb
POSTGRES_USER: dbuser
Expand Down
8 changes: 3 additions & 5 deletions src/Eccube/Controller/Admin/Product/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function index(Request $request, $page_no = null, PaginatorInterface $pag
/**
* @Route("/%eccube_admin_route%/product/classes/{id}/load", name="admin_product_classes_load", methods={"GET"}, requirements={"id" = "\d+"}, methods={"GET"})
* @Template("@admin/Product/product_class_popup.twig")
* @ParamConverter("Product")
* @ParamConverter("Product", options={"repository_method":"findWithSortedClassCategories"})
*/
public function loadProductClasses(Request $request, Product $Product)
{
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 0 additions & 8 deletions src/Eccube/Form/Type/Admin/OrderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
26 changes: 24 additions & 2 deletions src/Eccube/Form/Type/Admin/SearchProductType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/Eccube/Repository/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,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'];
Expand Down
7 changes: 7 additions & 0 deletions src/Eccube/Resource/template/admin/Product/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ file that was distributed with this source code.
</div>
</div>
<div class="col-6">
<div class="form-row mb-2">
<div class="col-6">
<label class="col-form-label">{{ 'admin.product.tag'|trans }}</label>
{{ form_widget(searchForm.tag_id) }}
{{ form_errors(searchForm.tag_id) }}
</div>
</div>
<div class="mb-2">
<label class="col-form-label">
{{ 'admin.common.create_date'|trans }}
Expand Down
13 changes: 10 additions & 3 deletions tests/Eccube/Tests/Doctrine/ORM/Tools/PaginationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping as ORM;
use Eccube\Entity\ProductTag;
use Eccube\Entity\Tag;
use Eccube\Repository\MemberRepository;
use Eccube\Repository\ProductRepository;
use Eccube\Repository\TagRepository;
Expand Down Expand Up @@ -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));

Expand All @@ -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([]);

Expand Down Expand Up @@ -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();
}

Expand Down
Loading

0 comments on commit 284dd59

Please sign in to comment.