Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Insert a PHP call in the product editor description, CMS block, CMS page, etc. 
 
radusl
Jr. Member
 
Total Posts:  11
Joined:  2013-03-30
 

I have a the following code which i use on my prudct pages.

<?php echo Mage::helper('stockstatus')->getListStatus(01); ?>

This code returns me the stock status of a specific product. In this case it returns me the stock status of product with ID 01. If i change 01 to 02, then it gives me product status of with ID 02.

This code works great if i insert it in any .phtml file in magento.

But i want to use it from the backend admin directly. For example i want to use in the description of the product editor, or on the CMS blocks or CMS pages. But i don’t know how.

My question is how to make it work when inserting in the description editor of a product or on the CMS blocks or CMS pages? Maybe i can create a widget? can somebody please guide me…

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

Hi radusl!

1) Create a template file and place that line of code and whatever else you require within it.
2) Assuming that the file you created is located at: app/design/frontend/base/default/template/test/test.phtml

you can include this template whever you like on a CMS page or within a Static Block using the following code:

{{block type="core/template" block_id="my_own_block" template="test/test.phtml"}}

Please note that you can of course place the template file under any theme, and assign it any name you wish. The filepath and name used above is just for this example.

I’m not sure if you can use that within a product description becuase I’ve never tried, I’m fairly sure though that you can’t and I don’t think that you cannot include any inline code at all with your product description without the aid of a third party extension or custom modification.

Hope it helps! grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
radusl
Jr. Member
 
Total Posts:  11
Joined:  2013-03-30
 

Hi MageParts,
Thank you for your reply smile
I tried your solution and it works. But my question is how can i write the ID of the product which the code is returning from the CSM page?  You see, I want to get the stock status of specific products by writing their ID manually in the CMS block and not to go into the .phtml.

In the code

<?php echo Mage::helper('stockstatus')->getListStatus(); ?>

there is this line:

getListStatus()
if i change that to
getListStatus(01)
it gives me the stock status of product with ID 01. Well. how can change the ID which the code is returning from the CMS page?
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top