diff --git a/app/DoctrineMigrations/Version20240312170000.php b/app/DoctrineMigrations/Version20240312170000.php new file mode 100644 index 00000000000..6c51a53e2d3 --- /dev/null +++ b/app/DoctrineMigrations/Version20240312170000.php @@ -0,0 +1,34 @@ +hasTable(self::NAME)) { + return; + } + + $blockExists = $this->connection->fetchOne("SELECT COUNT(*) FROM dtb_block WHERE file_name = 'auto_new_item'"); + if ($blockExists == 0) { + $this->addSql("INSERT INTO dtb_block (device_type_id, block_name, file_name, create_date, update_date, use_controller, deletable, discriminator_type) VALUES (10, '新着商品(自動取得)', 'auto_new_item', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '1', '0', 'block')"); + } + } + + public function down(Schema $schema): void + { + $this->addSql("DELETE FROM dtb_block WHERE file_name = 'auto_new_item'"); + } +} \ No newline at end of file diff --git a/app/config/eccube/packages/eccube.yaml b/app/config/eccube/packages/eccube.yaml index 3ca7c58715e..9e89a805bf2 100644 --- a/app/config/eccube/packages/eccube.yaml +++ b/app/config/eccube/packages/eccube.yaml @@ -173,3 +173,4 @@ parameters: - pdf eccube_login_throttling_max_attempts: 5 eccube_login_throttling_interval: '30 minutes' + eccube_max_number_new_items_get: 5 diff --git a/src/Eccube/Controller/Block/AutoNewItemController.php b/src/Eccube/Controller/Block/AutoNewItemController.php new file mode 100644 index 00000000000..061da5a04cc --- /dev/null +++ b/src/Eccube/Controller/Block/AutoNewItemController.php @@ -0,0 +1,61 @@ +productRepository = $productRepository; + $this->productListOrderByRepository = $productListOrderByRepository; + } + + /** + * @Route("/block/auto_new_item", name="block_auto_new_item") + * @Template("Block/auto_new_item.twig") + * + * @param Request $request + * @return array + */ + public function index(Request $request) + { + $qb = $this->productRepository->getQueryBuilderBySearchData([ + 'orderby' => $this->productListOrderByRepository->find($this->eccubeConfig['eccube_product_order_newer']), + ]) + ->setMaxResults($this->eccubeConfig['eccube_max_number_new_items_get']); + + return [ + 'Products' => $qb->getQuery()->getResult(), + ]; + } +} \ No newline at end of file diff --git a/src/Eccube/Resource/doctrine/import_csv/en/dtb_block.csv b/src/Eccube/Resource/doctrine/import_csv/en/dtb_block.csv index 6d7670dd12a..7b6e6a11840 100644 --- a/src/Eccube/Resource/doctrine/import_csv/en/dtb_block.csv +++ b/src/Eccube/Resource/doctrine/import_csv/en/dtb_block.csv @@ -14,3 +14,4 @@ id,device_type_id,block_name,file_name,create_date,update_date,use_controller,de 13,10,Product Search,search_product,2017-03-07 10:14:52,2017-03-07 10:14:52,1,0,block 14,10,Featured,topic,2017-03-07 10:14:52,2017-03-07 10:14:52,0,0,block 17,10,Calendar,calendar,2021-03-16 12:00:00,2021-03-16 12:00:00,1,0,block +18,10,Auto New Items,auto_new_item,2024-03-12 17:00:00,2024-03-12 17:00:00,1,0,block diff --git a/src/Eccube/Resource/doctrine/import_csv/ja/dtb_block.csv b/src/Eccube/Resource/doctrine/import_csv/ja/dtb_block.csv index 1487fcaf108..702b659bb2c 100644 --- a/src/Eccube/Resource/doctrine/import_csv/ja/dtb_block.csv +++ b/src/Eccube/Resource/doctrine/import_csv/ja/dtb_block.csv @@ -14,3 +14,4 @@ "13","10","商品検索","search_product","2017-03-07 10:14:52","2017-03-07 10:14:52","1","0","block" "14","10","トピック","topic","2017-03-07 10:14:52","2017-03-07 10:14:52","0","0","block" "17","10","カレンダー","calendar","2021-03-16 12:00:00","2021-03-16 12:00:00","1","0","block" +"18","10","新着商品(自動取得)","auto_new_item","2024-03-12 17:00:00","2024-03-12 17:00:00","1","0","block" diff --git a/src/Eccube/Resource/locale/messages.en.yaml b/src/Eccube/Resource/locale/messages.en.yaml index ad4a5395f92..6d2e63ecfec 100644 --- a/src/Eccube/Resource/locale/messages.en.yaml +++ b/src/Eccube/Resource/locale/messages.en.yaml @@ -120,6 +120,7 @@ front.block.eyecatch.view_list: See all front.block.new_item.title__en: NEW ITEMS front.block.new_item.title__ja: New Items front.block.new_item.more: More +# Deprecated https://github.com/EC-CUBE/ec-cube/pull/4920 front.block.new_item.item_1_name: "Colorful Gelato: 'CUBE'" front.block.new_item.item_1_price: $1,200 (tax incl.) front.block.new_item.item_2_name: Cherry Ice Cream Sandwiches diff --git a/src/Eccube/Resource/locale/messages.ja.yaml b/src/Eccube/Resource/locale/messages.ja.yaml index 29b77e5cc7c..3eebb71ef9d 100644 --- a/src/Eccube/Resource/locale/messages.ja.yaml +++ b/src/Eccube/Resource/locale/messages.ja.yaml @@ -120,6 +120,7 @@ front.block.eyecatch.view_list: 一覧を見る front.block.new_item.title__en: NEW ITEM front.block.new_item.title__ja: 新着商品 front.block.new_item.more: more +# Deprecated https://github.com/EC-CUBE/ec-cube/pull/4920 front.block.new_item.item_1_name: 彩のジェラート"CUBE" front.block.new_item.item_1_price: ¥1,200(税込) front.block.new_item.item_2_name: チェリーアイスサンド diff --git a/src/Eccube/Resource/template/default/Block/auto_new_item.twig b/src/Eccube/Resource/template/default/Block/auto_new_item.twig new file mode 100644 index 00000000000..a58337747dc --- /dev/null +++ b/src/Eccube/Resource/template/default/Block/auto_new_item.twig @@ -0,0 +1,42 @@ +{# +This file is part of EC-CUBE + +Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. + +http://www.ec-cube.co.jp/ + +For the full copyright and license information, please view the LICENSE +file that was distributed with this source code. +#} + +{% if Products is defined %} +