Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

Commit

Permalink
Add column filter for non-English URL rewrites
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Yam authored and Matthew Gamble committed May 21, 2015
1 parent dd53c51 commit 47e708a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

class BL_CustomGrid_Model_Custom_Column_Urldecoded extends BL_CustomGrid_Model_Custom_Column_Simple_Duplicate
{
/**
* Return forced grid column block values
* (you can check BL_CustomGrid_Model_Custom_Column_Abstract::getBlockValues() for the priorities
* of the different methods related to block values)
*
* @param Mage_Adminhtml_Block_Widget_Grid $gridBlock Grid block
* @param BL_CustomGrid_Model_Grid $gridModel Grid model
* @param string $columnBlockId Grid column block ID
* @param string $columnIndex Grid column index
* @param array $params Customization params values
* @param Mage_Core_Model_Store $store Column store
* @return array
*/
public function getForcedBlockValues(
Mage_Adminhtml_Block_Widget_Grid $gridBlock,
BL_CustomGrid_Model_Grid $gridModel,
$columnBlockId,
$columnIndex,
array $params,
Mage_Core_Model_Store $store
) {
return array(
'renderer' => 'customgrid/widget_grid_column_renderer_text_urldecoded',
'filter_condition_callback' => array($this, 'addFilterToGridCollection'),
);
}

/**
* @param Mage_Core_Model_Resource_Url_Rewrite_Collection $collection
* @param Mage_Adminhtml_Block_Widget_Grid_Column $columnBlock
*/
public function addFilterToGridCollection($collection, Mage_Adminhtml_Block_Widget_Grid_Column $columnBlock)
{
$filter = $columnBlock->getFilter();
$value = $filter->getValue();
$filter->setValue(urlencode($value));
$collection->addFieldToFilter($this->getDuplicatedFieldName(), $filter->getCondition());
$filter->setValue($value);
}
}
29 changes: 10 additions & 19 deletions app/code/community/BL/CustomGrid/etc/customgrid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,39 +386,30 @@
<name>URL Rewrite</name>
<sort_order>300000</sort_order>
<custom_columns>
<request_path_urldecoded model="customgrid/custom_column_simple_duplicate" module="customgrid">
<id_path_urldecoded model="customgrid/custom_column_urldecoded" module="customgrid">
<name>ID Path (URL Decoded)</name>
<group>Duplicated</group>
<allow_renderers>1</allow_renderers>
<config_params>
<duplicated_field_name>id_path</duplicated_field_name>
</config_params>
</id_path_urldecoded>
<request_path_urldecoded model="customgrid/custom_column_urldecoded" module="customgrid">
<name>Request Path (URL Decoded)</name>
<group>Duplicated</group>
<allow_renderers>1</allow_renderers>
<config_params>
<duplicated_field_name>request_path</duplicated_field_name>
</config_params>
<block_params>
<renderer>customgrid/widget_grid_column_renderer_text_urldecoded</renderer>
</block_params>
</request_path_urldecoded>
<target_path_urldecoded model="customgrid/custom_column_simple_duplicate" module="customgrid">
<target_path_urldecoded model="customgrid/custom_column_urldecoded" module="customgrid">
<name>Target Path (URL Decoded)</name>
<group>Duplicated</group>
<allow_renderers>1</allow_renderers>
<config_params>
<duplicated_field_name>target_path</duplicated_field_name>
</config_params>
<block_params>
<renderer>customgrid/widget_grid_column_renderer_text_urldecoded</renderer>
</block_params>
</target_path_urldecoded>
<id_path_urldecoded model="customgrid/custom_column_simple_duplicate" module="customgrid">
<name>ID Path (URL Decoded)</name>
<group>Duplicated</group>
<allow_renderers>1</allow_renderers>
<config_params>
<duplicated_field_name>target_path</duplicated_field_name>
</config_params>
<block_params>
<renderer>customgrid/widget_grid_column_renderer_text_urldecoded</renderer>
</block_params>
</id_path_urldecoded>
</custom_columns>
</core_urlrewrite>

Expand Down

0 comments on commit 47e708a

Please sign in to comment.