Is there a shortcut where I can supply a product ID inside a tag and use that to have Magento render the correct URL?
I want to link to other products from a current product's description.
I know I can use widgets for this but that seems like a lot of steps to do.
Solved! Go to Solution.
@mikecorrac Yes that's actually same, same kind of logic you can use apply with little modification. tag changes on backend and parse same on frontend... of course dynamically.
If it is the product details page then you can use the Magento Upsell functionality.
Seems like you want to add another products link into current product description.... hummm.. Possible but you need to write little piece of code. let me help you by writing sample php code.
As you've said apply product id so I assume and go with product id wise. Add product id tag wise into description, just like.
Lorem Ipsum is simply dummy text <product_id>121</product_id> of the printing and typesetting industry
php code to achieve it.
<?php function getTagsIds($string, $tagname) { $pattern = "/<$tagname>([\w\W]*?)<\/$tagname>/"; if(preg_match($pattern, $string, $matches)) return $matches; } $description = 'Lorem Ipsum is simply dummy text <product_id>121</product_id> of the printing and typesetting industry'; $ids = getTagsIds($description, "product_id"); if(!empty($ids)){ foreach($ids as $id){ $description = str_replace("<product_id>$id</product_id>", "<a href='http://www.google.com'>Test</a>", $description); } } echo $description;
Just implement same into Magento files and you're done. Good luck
That isn't exactly what I meant. I was seeing firstly if Magento had a stock function for doing this. Similar to this:
<a href="{{store url="page_identifier_here"}}#something">Anchor text here</a>
But if I was going to write code it would have to be dynamic since it would need to parse the tag wherever it lives on the site
You probably want to check out product widgets: http://magento.stackexchange.com/questions/11674/cms-block-widgets-for-individual-products
I saw that too, I would have to create a widget for each and every product, that seems silly to me.
@mikecorrac Yes that's actually same, same kind of logic you can use apply with little modification. tag changes on backend and parse same on frontend... of course dynamically.
We ended up writing our own solution based loosely on your suggestion, thanks
@mikecorrac wrote:I saw that too, I would have to create a widget for each and every product, that seems silly to me.
The whole point of widget is that you do not create them for each and every product. Widgets are smart blocks: all you need to do is to give it a product code (which you need to have there anyways) and it does everything else.