Returns a list of products based on a given product_id attribute. The content within the tag pair will only be returned if there are products related to the given product id.
Example from Blank Template: file(product/index)
{exp:brilliant_retail:product_related product_id="{product_id}"}
<div id="related">
<h3>Related Products</h3>
<ul>
{related_products}
<li {switch='|class="even"'}>
<div class="pic">
<a href="{path='product/{related_url}'}">
{exp:brilliant_retail:image src="{related_thumb}" width="180" height="150"}
</a>
</div>
<h5>{exp:snippet total="50"}{related_title}{/exp:snippet}</h5>
<p><a href="{path='product/{related_url}'}">Details</a></p>
</li>
{/related_products}
</ul>
<div class="clearboth"><!-- --></div>
</div> <!-- related -->
{/exp:brilliant_retail:product_related}
Comments
By Jump Frog on Monday October 10th, 2011 at 5:03pm
Still a bit new to this…any way to get the related products price inside this tag?
By Anthony Cooper on Thursday October 20th, 2011 at 4:57am
+1 for that, would also like a {related_detail} if at all possible. Thanks!
By Jump Frog on Thursday October 20th, 2011 at 1:26pm
Here’s some php (using code igniter as well) that I put together to get related products on the fly since brilliant retail doesn’t handle it so well.
$query = $this->EE->db->query(“SELECT * FROM exp_br_product_related WHERE parent_id = ‘{product_id}’”);
foreach($query->result() as $row){
$related_ids[] = $row->product_id;
}
foreach($related_ids as $value){
$query = $this->EE->db->query(“SELECT * FROM exp_br_product WHERE product_id = ‘$value’”);
$row = $query->row();
Remember to enable php on your template!
By Anthony Cooper on Monday October 24th, 2011 at 11:26am
Thanks Jump Frog. I don’t usually like straying from the standard functionality to make sure I don’t run into problems down the road, but this was a must for the client. Ended up doing:
<?
$product = $this->EE->uri->segment(2);
$sql = <<<SQL
SELECT
r.product_id
FROM
exp_br_product p
INNER JOIN exp_br_product_related r ON r.parent_id = p.product_id
WHERE
p.url = ‘$product’
ORDER BY
RAND() LIMIT 3;
SQL;
$query = $this->EE->db->query($sql);
?>
Which just gave me some product_id’s to loop over then I could use the standard {exp:brilliant_retail:product} tag to retrieve/format all the variables.
By Stephen Davis on Thursday December 1st, 2011 at 2:42pm
This might be even easier. Try putting this after your closing product tag ({/exp:brilliant_retail:product}), and replace {segment_3} with whatever you’re using:
{exp:brilliant_retail:product_related product_id=”{exp:brilliant_retail:product url_title=’{segment_3}’ form=‘no’}{product_id}{/exp:brilliant_retail:product}” parse=“inward”}{related_products}
{exp:brilliant_retail:product url_title=”{related_url}” parse=“inward”}
// In here you can use any of the {product} internal tags, like {price_html}
{/exp:brilliant_retail:product}
{/related_products}
{/exp:brilliant_retail:product_related}
By Stephen Davis on Thursday December 1st, 2011 at 2:43pm
Not sure why it’s split into three. All of the above code goes together.
Add Your Comments
You must be logged in to comment.