好了,这不是我第一次大规模行动,但是,这并不有我抓我的头。
我做了一个模块CLR_exportMassAction。 部署它历久弥新的本地主机,没有任何问题。 然而,当我将文件移动了我的服务器,没有任何反应。 我已重建索引和刷新缓存。 我有一种感觉它的一些配置古怪和Magento的是不是我的模块中挂钩。
这里是我的代码:\本地\ CLR \ exportMassAction \等\ config.xml中
<?xml version="1.0" encoding="UTF-8"?>
<config>
<global>
<models>
<CLR_exportMassAction>
<class>CLR_exportMassAction_Model</class>
</CLR_exportMassAction>
</models>
</global>
<adminhtml>
<events>
<adminhtml_block_html_before>
<observers>
<CLR_exportMassAction>
<type>singleton</type>
<class>CLR_exportMassAction/observer</class>
<method>addExportMassactionToProductGrid</method>
</CLR_exportMassAction>
</observers>
</adminhtml_block_html_before>
</events>
</adminhtml>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<CLR_exportMassAction before="Mage_Adminhtml">CLR_exportMassAction_Adminhtml</CLR_exportMassAction>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
当地\ CLR \ exportMassAction \型号\ Observer.php
<?php
class CLR_exportMassAction_Model_Observer
{
public function addExportMassactionToProductGrid($observer)
{
$block = $observer->getBlock();
if($block instanceof Mage_adminHtml_Block_Catalog_Product_Grid) {
$block ->getMassactionBlock()->addItem('export', array(
'label' => Mage::helper('catalog')->__('Export to CSV'),
'url' => $block->getUrl('*/*/massExport', array('_current'=>true)),
));
}
}
}
当地\ CLR \ exportMassAction \控制器\ Adminhtml \目录\ ProductController.php
<?php
class CLR_exportMassAction_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Controller_Action
{
public function massExportAction()
{
$productIds = $this->getRequest()->getParam('product');
if (!is_array($productIds)) {
$this->_getSession()->addError($this->__('Please select product(s).'));
$this->_redirect('*/*/index');
}
else {
//write headers to the csv file
$content = "id,name,url,sku\n";
try {
foreach ($productIds as $productId) {
$product = Mage::getSingleton('catalog/product')->load($productId);
$content .= "\"{$product->getId()}\",\"{$product->getName()}\",\"{$product->getProductUrl()}\",\"{$product->getSku()}\"\n";
}
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
$this->_redirect('*/*/index');
}
$this->_prepareDownloadResponse('export.csv', $content, 'text/csv');
}
}
}
应用程序\等\ CLR_exportMassAction.xml
<config>
<modules>
<CLR_exportMassAction>
<active>true</active>
<codePool>community</codePool>
</CLR_exportMassAction>
</modules>
</config>
我只是在寻找一个指针确实在哪里何去何从; 我不知道下一个故障排除选项。