<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Related products - &quot;You may also like..&quot;]]></title><description><![CDATA[<p dir="auto">Hi all, what's the easiest way to show 'related product' at the bottom of each product page?</p>
]]></description><link>https://community.oncord.com/topic/34/related-products-you-may-also-like</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 14:58:52 GMT</lastBuildDate><atom:link href="https://community.oncord.com/topic/34.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 06 Feb 2025 02:18:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Related products - &quot;You may also like..&quot; on Wed, 12 Feb 2025 01:47:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.oncord.com/uid/549">@iwNZ</a> Hi there.</p>
<p dir="auto">I have implemented at least 2 very popular methods in the past.</p>
<p dir="auto"><strong>Option 1</strong>: (<em>Moderate</em>) Show all products from the current category<br />
<strong>Option 2</strong>: (<em>Advanced</em>) Custom Field called Related Products</p>
<p dir="auto"><strong>Option 1</strong>:<br />
On product detail template:</p>
<pre><code>&lt;logic:variable as="arrCategoryIds" value="[? \Components\Commerce\Products\Categories::getAllIdsForProduct($product['product_id']) ?]" /&gt;
&lt;logic:variable as="category" value="[? \Components\Commerce\Products\Categories::get($arrCategoryIds[0]) ?]" /&gt;

&lt;div class="categoryRow"&gt;
	&lt;h2&gt;Category Products &lt;small&gt;([? $category['product_category_title'] ?])&lt;/small&gt;&lt;/h2&gt;
	&lt;div class="shop-grid"&gt;
		&lt;logic:variable as="currentProduct" value="[? $product ?]" /&gt;
		&lt;data:repeater id="grid-product" class="grid-product-wrap" as="product"
			datasource="\Components\Commerce\Products::getAllForCategoryAndBrandRecursive($category['product_category_id'], null)"
			paging="true" pagingrows="20" pagingautorender="true"
		&gt;
			&lt;data:template component="\Components\Commerce\Products" type="list" /&gt;
		&lt;/data:repeater&gt;
		&lt;logic:variable as="product" value="[? $currentProduct ?]" /&gt;
	&lt;/div&gt;
&lt;/div&gt;

</code></pre>
<p dir="auto"><strong>Option 2</strong>:<br />
This option is a lot more complicated:</p>
<ul>
<li>step 1 you need to create a custom field called Related Product Ids. Use a Custom UI type, and choose Text &lt; 255 Characters.</li>
<li>step 2 then on each product you select your related products</li>
<li>step 3 add a data:repeater on the product detail page to list through the related product ids, a lot like what I showed in <strong>option 1</strong>.</li>
</ul>
<p dir="auto">Your Custom UI code should look like this, or similar:</p>
<pre><code>&lt;forms:row label="Related Products"&gt;
	&lt;logic:variable as="selected_product_ids" value="[? [] ?]" /&gt;
	&lt;logic:if test="$product['product_related_products']"&gt;
		&lt;logic:variable as="selected_product_ids" value="[? unserialize( $product['product_related_products'] ) ?]" /&gt;
	&lt;/logic:if&gt;
	
	&lt;forms:selectlist id="product_related_products" datacolumn="product_related_products" value="" as="relatedProduct" width="300" height="120" style="font-size: 80%;"&gt;
		&lt;forms:option value=""&gt;&lt;/forms:option&gt;
		
		&lt;data:repeater as="relatedProduct" datasource="\Components\Commerce\Products::getAllConsole()"&gt;
		
			&lt;logic:if test="in_array($relatedProduct['product_id'], $selected_product_ids, false)"&gt;
				&lt;forms:option value="[? $relatedProduct['product_id'] ?]" title="[? $relatedProduct['product_title'] ?]" selected="selected" /&gt;
			&lt;/logic:if&gt;
			&lt;logic:else&gt;
				&lt;forms:option value="[? $relatedProduct['product_id'] ?]" title="[? $relatedProduct['product_title'] ?]" /&gt;
			&lt;/logic:else&gt;
			
		&lt;/data:repeater&gt;
		
	&lt;/forms:selectlist&gt;
	
	&lt;p style="margin-top: 8px;"&gt;&lt;em&gt;&lt;small&gt;Hold CMD or Ctrl to select multiple products&lt;/small&gt;&lt;/em&gt;&lt;/p&gt;

&lt;/forms:row&gt;
</code></pre>
<p dir="auto">Hope this sets you on the right path.</p>
]]></description><link>https://community.oncord.com/post/76</link><guid isPermaLink="true">https://community.oncord.com/post/76</guid><dc:creator><![CDATA[StephenBlignault]]></dc:creator><pubDate>Wed, 12 Feb 2025 01:47:56 GMT</pubDate></item></channel></rss>