We are having issues with the WYSIWYS editor messing up our embed codes for videos.
One solution we came up with is to make the embed code its own attribute, then call that attribute from within the product description.
Is that even possible?
We don’t want to add it to the .phtml, We would rather place it in the description.
As it is, this is impossible if you plan to do it without any code modification at all.
However, if you want to process something in the description by calling a whole new function in Mage_Catalog_Model_Product
, say like
$_product = Mage::getModel('catalog/product');
$_product->getProcessedDescription(); // assuming this is the function you will be using in stead of $_product->getDescription(); in your PHTML files
then say you like your product descriptions to be like:
Lorem Ipsum Dolor Test Description
See our video below!
[[video]]
Where video
is a custom product attribute
you can rewrite the Mage_Catalog_Model_Product class in order to get your new function in. To do that, create a module!
app/etc/modules/Electricjesus_Processeddescription.xml:
<?xml version="1.0"?>
<config>
<modules>
<Electricjesus_Processeddescription>
<active>true</active>
<codePool>local</codePool>
<version>0.0.1</version>
</Electricjesus_Processeddescription>
</modules>
</config>
app/code/local/Electricjesus/Processeddescription/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Electricjesus_Processeddescription>
<version>0.0.1</version>
</Electricjesus_Processeddescription>
</modules>
<global>
<models>
<catalog>
<rewrite>
<product>Electricjesus_Processeddescription_Model_Product</product>
</rewrite>
</catalog>
</models>
</global>
</config>
app/code/local/Electricjesus/Processeddescription/Model/Product.php:
<?php
class Electricjesus_Processeddescription_Model_Product extends Mage_Catalog_Model_Product {
public function getProcessedDescription() {
$desc = $this->getDescription();
return preg_replace("/\[\[video\]\]/", $this->getVideo(), $desc);
}
}
//NEVER close <?php tags in Magento class files!
Then you should be able to use $_product->getProcessedDescription()
in your .phtml files.
Obviously there are alot of stuff missing and it all seems that it is pretty much a hack (I'm not even sure about my preg_replace statement) but you get the idea. What we did here is to make a module solely just to rewrite a magento core class to do some more processing!
Additionally, you might also want to get a copy of a Magento Cheatsheet for more information about rewriting.
Good luck!
Seth