Php 如何在Magento中重命名按文本排序
我需要重命名magento 1.9.2类别中的默认排序方式选项。Php 如何在Magento中重命名按文本排序,php,magento,magento-1.9,Php,Magento,Magento 1.9,我需要重命名magento 1.9.2类别中的默认排序方式选项。 这些是我的magento排序选项 “职位” “日期” “姓名”等 在这里,我想将“位置”改为“流行”,将“日期”改为“最新”。 帮助我解决这些问题。为了实现这一点,您需要覆盖在类别编辑屏幕中显示产品网格的块。此块是Mage\u Adminhtml\u块\u目录\u类别\u选项卡\u产品。 为此,创建一个新模块。我们用以下文件将其命名为Easylife\u Adminhtml: app/etc/modules/Easylife\
这些是我的magento排序选项
- “职位”
- “日期”
- “姓名”等
帮助我解决这些问题。为了实现这一点,您需要覆盖在类别编辑屏幕中显示产品网格的块。此块是
Mage\u Adminhtml\u块\u目录\u类别\u选项卡\u产品
。
为此,创建一个新模块。我们用以下文件将其命名为Easylife\u Adminhtml
:
app/etc/modules/Easylife\u 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/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();
}
}
打开文件app\design\frontend\your\u 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>
Mage::helper('core')->quoteEscape($this->\('Sort By'))?>“>
您好,欢迎来到stack overflow。我和社区的其他人都很乐意为您提供帮助,但我想我们需要更多的信息。您想做什么?您能提供一些解决此问题的示例代码吗?我只想将排序方式中显示的字段从“位置”重命名为“流行”,并将“日期”重命名为最新的“所有,没有其他编码是必需的。
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>
<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>