php - Magento admin grid column formatting - renderer? -


I want to show the sales_order_create grid to show both price and special price in the same column, and I did this by adding The: _prepareCollection () function, and then to add:

  
  -> addAttributeToSelect ('special_price')   

code > $ This- & gt; AddColumn ('special_price', array ('header' = & gt; mega :: helper ('sale') - & gt; __ ('special value'), 'sort' = & gt; wrong, 'index' = & Array ('value', 'special_pris'), 'type' = & gt; 'concat', 'separator' => gt; '-', 'width' => '140px',));

_prepareColumns () function on

This works! The result is a new column, which shows as an example:

79.9800 - 34.9900

How can I format it, so is it in currency format? A £ xx.xx

Besides, is this style possible? So it looks like: £ 79.98 (£ 34.99)

If it is not possible for style, then the currency format will be great.

I think there is something to do with this renderer but I'm new to Magento so it will explain in basic way if it's okay.

Thanks

I have been able to do this work, my code is terrible , But it can help someone who stays in the future.

I looked at the Price column and saw:

  'Renderer' = & gt; After navigating to the app / code / core / pimple / admin / block / widget / grid / column / renderer, I saw a contact renderer.    P> I have copied Concat.php from this directory and created a local version, I have given it a special .php name to avoid any collision:  

/ app / code / local / mage / adminhtml / block / widget / grid / column / renderer / special Php

Then I added my renderer to my special_pris column:

  'renderer' = & gt; 'Adminhtml / sales_order_create_search_grid_renderer_special',   

My specials The php code is as follows (WARNING: This code is very awesome, but it works so I'm happy):

  Class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Special Extended Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {/ ** * Grid Columns * * @ Varien_Object $ line * @ return string * / render public function (Varien_Object $ line) {$ dataArr = array (); Foreach ($ this-> getColumn) - & gt; GetIndex () as $ index) {if ($ data = $ line-> match ($ index)) {// $ dataArr [] = $ data; $ Datair [] = number-format (float) $ data, 2, '.', ''); }} $ Data = join ($ this-> getColumn () - & gt; Miller (), $ dataArr); // Todo column type renderer $ value = ''; $ Special = ''; If (strlen ($ dataArr [0]) gt; 0) {if strlen ($ dataArr [1]); gt; {$ price = '& lt; span style = "text-decoration: line-medium" & gt; & Amp; Pound, '. $ Datair [0]' '; $ special =' and pound; '$. $ DataArr [1];} and {$ price =' & amp; £; $. DataArr [0]; $ special = '';}} return value $ $ special;}}   

The result is that no cost (grouped product) entry is empty, If there is no special entry then there is an RRP and if there is a special entry rrp special value

I am sure Can be improved Od but it works

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -