その他 > その他 > タグ付けをした商品のリストを表示する。 |
その他
フラット表示 | 前のトピック | 次のトピック |
投稿者 | スレッド |
---|---|
banajin |
投稿日時: 2024/1/5 18:17
対応状況: −−−
|
常連 ![]() ![]() 登録日: 2023/10/24 居住地: 投稿: 39 |
タグ付けをした商品のリストを表示する。 ▼テンプレート
[EC-CUBE] 4.2.2 [レンタルサーバ] ローカル環境 [OS] 使用しているOS名、バージョン [PHP] 7.3.33 MAMPのローカルServerで環境構築してます。 [現象] 再現手順や、どのような現象が発生しているかなど、具体的に タイトルの通りタグ付けした商品のみをリストにしたいのですができません。 コードはネットを参考にしたりチャットgptで書いてみましたが何も表示されません。 {# Productエンティティを取得 #} {% set productRepository = repository('Eccube\\Entity\\Product') %} {% set products = productRepository.findBy({}, {'id': 'desc'}, 24) %} {# Tagエンティティを取得 #} {% set tagRepository = repository('ECcube\\Entity\\Tag') %} {% set tags = tagRepository.findBy({'id':5}) %} <div class="newArrival__list newProduct"> {# TagエンティティからProductエンティティを取得し、表示する #} {% for tag in tags %} {% set productsWithTag = tag.getProducts() %} {% for product in productsWithTag %} <div class="newProduct__box"> <a href="{{ url('product_detail', {'id': product.id}) }}"> <div class="newProduct__imgCase"> <img class="newProduct__img" src="{{ asset(product.main_list_image|no_image_product, 'save_image') }}"> </div> <p class="newProduct__name">{{ product.name }}</p> <p class="newProduct__price">{{ product.getPrice02IncTaxMax|price }}</p> </a> </div> {% endfor %} {% endfor %} </div> 以上、どうかよろしくおねがいします。 |
フラット表示 | 前のトピック | 次のトピック |
題名 | 投稿者 | 日時 |
---|---|---|
» ![]() |
banajin | 2024/1/5 18:17 |
![]() |
tattsu | 2024/1/5 18:33 |
![]() |
banajin | 2024/1/5 21:20 |
![]() |
tattsu | 2024/1/5 21:37 |
![]() |
banajin | 2024/1/5 22:19 |
![]() |
tattsu | 2024/1/6 11:57 |
![]() |
banajin | 2024/1/6 16:00 |
![]() |
tattsu | 2024/1/6 17:26 |
![]() |
banajin | 2024/1/9 0:02 |
![]() |
tattsu | 2024/1/9 9:14 |
![]() |
banajin | 2024/1/5 22:26 |
![]() |
tattsu | 2024/1/6 12:46 |
