# バリエーションがある商品を各バリエーションとも一覧ページへ表示したい

**URL:** <https://www.nocode-faq.com/t/topic/2483>\
**Category:** shopify\
**Tags:** ツールの操作方法\
**Created:** [2021 年 12 月 28 日午前 6:54 UTC](https://www.nocode-faq.com/t/topic/2483 "2021-12-28T06:54:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kumiko.kume](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kumiko.kume](https://www.nocode-faq.com/u/kumiko.kume)\
**Post date:** [2021 年 12 月 28 日午前 6:54 UTC](https://www.nocode-faq.com/t/topic/2483/1 "2021-12-28T06:54:55Z")

</div>

フリーのテーマをベースに利用して制作する前提です。  
カラーバリエーションがある商品（例えば、「TシャツA」という商品名で白、黄、赤、青の色違いがある）を各色全て商品一覧ページに表示したいのですが、そういった事はできますでしょうか？  
白だけでなく、黄色や赤のTシャツも一覧ページに並列に表示されているイメージです。

ご教授いただけますと幸いです。よろしくお願いいたします。

---

<div class="post-metadata">

**Author:** ![tsubasa](https://sea2.discourse-cdn.com/flex020/user_avatar/www.nocode-faq.com/tsubasa/32/8670_2.png) [@tsubasa](https://www.nocode-faq.com/u/tsubasa)\
**Post date:** [2021 年 12 月 28 日午後 2:10 UTC](https://www.nocode-faq.com/t/topic/2483/2 "2021-12-28T14:10:07Z")

</div>

私も得意ではない分野ですが、基本はLiquidでの編集になると思います。  
トップページの商品一覧で、カラーバリエーションを一覧で表示したいってことですよね？  
Liquid 構文タグ で、Variants をLoopすればできるようです。

テーマのコード編集 で、Product一覧を表示するところに、例えば、以下のようなコードを入力します。 (テーマによって違う）

```auto
{% for tag in collection.all_tags %}
{% capture current_tag %}/{{ tag }}/{% endcapture %}
	<div class="small-12 columns cat-divider"></div>
	<div class="small-12 columns cat-title">
		<h3 class="lowercase">{{ tag }}</h3>
	</div>
	{% for product in collection.products %}
		{% for product_tag in product.tags %}
		{% capture current_tag2 %}/{{ product_tag }}/{% endcapture %}
			{% if current_tag contains current_tag2 %}
					{% assign seen_variants ='' %}
				
					{% for variant in product.variants %}
						{% assign variant_options = '' %}
						{% unless product.options[0] == 'Size' %}
							{% assign variant_options = variant_options | append: ",," | append: variant.option1 %}
						{% endunless %}
						{% unless product.options[1] == 'Size' %}
							{% assign variant_options = variant_options | append: ",," | append: variant.option2 %}
						{% endunless %}
						{% unless product.options[2] == 'Size' %}
							{% assign variant_options = variant_options | append: ",," | append: variant.option3 %}
						{% endunless %}
				
						{% assign variant_options = variant_options | replace: ",,", " " | strip %}
				
						{% unless seen_variants contains variant_options and seen_variants != '' %}
							{% assign seen_variants = seen_variants | append: ",," | append: variant_options %}
							{% include 'product-list-single' with collection.handle %}
						{% endunless %}
					{% endfor %}
			{% else %}
			{% endif %}
		{% endfor %}
	{% endfor %}
{% endfor %}

```

> **[Looping through variants and displaying as individual products in collections...](https://community.shopify.com/c/shopify-design/looping-through-variants-and-displaying-as-individual-products/td-p/436193)**
>
> I am currrently looping through the variants and displaying them as individual products, however I am having some issues of specifically looping through the color options as opposed to all color/size combinations. For example, a product with 2 colors...

タグ参考

> **[The product object](https://shopify.dev/api/liquid/objects/product#product-variants)**
>
> About the Shopify Liquid product object.

あと、調べたら、こちらのShopipy APPでも同じように使えそうです。

> **[Products List Variants Viewer - Show products variants in collection with...](https://apps.shopify.com/variants-in-collections?utm_source=avada.io&utm_medium=avada.io&utm_campaign=app-review&utm_content=Products%20List%20Variants%20Viewer&ref=avada)**
>
> Show products variants in collection with "Add to cart" button

他、Shopify詳しい人いたら補足お願いしますー

---

<div class="post-metadata">

**Author:** ![kumiko.kume](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kumiko.kume](https://www.nocode-faq.com/u/kumiko.kume)\
**Post date:** [2022 年 1 月 4 日午後 12:52 UTC](https://www.nocode-faq.com/t/topic/2483/3 "2022-01-04T12:52:46Z")

</div>

返信が遅れ失礼いたしました。

つばささん、情報ありがとうございます！  
試してみます！

---

<div class="post-metadata">

**Author:** ![tsubasa](https://sea2.discourse-cdn.com/flex020/user_avatar/www.nocode-faq.com/tsubasa/32/8670_2.png) [@tsubasa](https://www.nocode-faq.com/u/tsubasa)\
**Post date:** [2022 年 1 月 4 日午後 1:19 UTC](https://www.nocode-faq.com/t/topic/2483/4 "2022-01-04T13:19:39Z")

</div>

いえいえ、気にしてないですよー。  
ぜひ、試してみてくださいね＾＾
