我需要重命名magento 1.9.2类别中的默认排序选项 这些是我的magento排序选项
在这里,我想改变"位置"到了#34;热门"和"日期"到"最新"。
帮我解决这些问题。
答案 0 :(得分:0)
为了实现此目的,您需要覆盖在类别编辑屏幕中显示产品网格的块。该块为Mage_Adminhtml_Block_Catalog_Category_Tab_Product
。
为此,请创建一个新模块。我们使用以下文件将其称为Easylife_Adminhtml
:
app/etc/modules/Easylife_Adminhtml.xml
- 模块声明文件。
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Adminhtml>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Adminhtml />
</depends>
</Easylife_Adminhtml>
</modules>
</config>
app/code/local/Easylife/Adminhtml/etc/config.xml
- 模块配置文件
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Adminhtml>
<version>0.0.1</version>
</Easylife_Adminhtml>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<catalog_category_tab_product>Easylife_Adminhtml_Block_Catalog_Category_Tab_Product</catalog_category_tab_product><!-- override the default block with your ownw-->
</rewrite>
</adminhtml>
</blocks>
</global>
</config>
app/code/local/Easylife/Adminhtml/Block/Catalog/Category/Tab/Product.php
- 块覆盖类。
<?php
class Easylife_Adminhtml_Block_Catalog_Category_Tab_Product extends Mage_Adminhtml_Block_Catalog_Category_Tab_Product{
protected function _prepareCollection()
{
if ($this->getCategory()->getId()) {
$this->setDefaultFilter(array('in_category'=>1));
}
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('name')
->addAttributeToSelect('sku')
->addAttributeToSelect('price')
->addStoreFilter($this->getRequest()->getParam('store'))
->joinField('position',
'catalog/category_product',
'position',
'product_id=entity_id',
'category_id='.(int) $this->getRequest()->getParam('id', 0),
'left');
$this->setCollection($collection);
if ($this->getCategory()->getProductsReadonly()) {
$productIds = $this->_getSelectedProducts();
if (empty($productIds)) {
$productIds = 0;
}
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
}
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
if (!$this->getCategory()->getProductsReadonly()) {
$this->addColumn('in_category', array(
'header_css_class' => 'a-center',
'type' => 'checkbox',
'name' => 'in_category',
'values' => $this->_getSelectedProducts(),
'align' => 'center',
'index' => 'entity_id'
));
}
$this->addColumn('entity_id', array(
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => '60',
'index' => 'entity_id'
));
$this->addColumn('name', array(
'header' => Mage::helper('catalog')->__('Name'),
'index' => 'name'
));
$this->addColumn('sku', array(
'header' => Mage::helper('catalog')->__('SKU'),
'width' => '80',
'index' => 'sku'
));
$this->addColumn('position', array(
'header' => Mage::helper('catalog')->__('Popular'),
'width' => '1',
'type' => 'number',
'index' => 'position',
'editable' => !$this->getCategory()->getProductsReadonly()
//'renderer' => 'adminhtml/widget_grid_column_renderer_input'
));
return parent::_prepareColumns();
}
}
转到_prepareColumns()
并将'header' => Mage::helper('catalog')->__('Position'),
的值更改为'header' => Mage::helper('catalog')->__('Popular'),
日期也一样。
希望这会有所帮助。
答案 1 :(得分:0)
打开文件app \ design \ frontend \ your_theme \ default \ template \ catalog \ product \ list \ toolbar.phtml
找到代码:
Mage::helper('core')->quoteEscape($this->__('Sort By')) ?>">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select>
在此代码中,“$ _order”包含所有short参数。您可以从中管理您的参数。
例如:
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Sort By')) ?>">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
<?php if ($_order == 'Position'):?>
<?php echo $this__("Popular")?>
<?php endif; ?>
<?php if ($_order == 'Date'):?>
<?php echo $this__("Newest")?>
<?php endif; ?>
</option>
<?php endforeach; ?>
</select>