Magento Mass Action,网格不会更新 [英] Magento Mass Action, grid does not update

查看:75
本文介绍了Magento Mass Action,网格不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以这不是我的第一个大规模动作,但这确实让我挠头.

ok, so this isn't my first mass action but, this does have me scratching my head.

我制作了一个模块CLR_exportMassAction.毫无问题地将其部署在良好的旧localhost上.但是,当我将文件移到服务器上时,什么也没有发生.我已重新编制索引并刷新了缓存.我感觉到它的某些配置很奇怪,而且magento没有挂在我的模块上.

I made a module CLR_exportMassAction. Deployed it on the good old localhost with no problems. However when I move the files out to my server, nothing happens. I have reindexed and flushed caches. I have a feeling its some configuration weirdness and magento isn't hooking in my module.

这是我的代码: \ local \ CLR \ exportMassAction \ etc \ config.xml

Here is my code: \local\CLR\exportMassAction\etc\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>

local \ CLR \ exportMassAction \ Model \ Observer.php

local\CLR\exportMassAction\Model\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)),
                   ));
        }
}



}

local \ CLR \ exportMassAction \ controllers \ Adminhtml \ Catalog \ ProductController.php

local\CLR\exportMassAction\controllers\Adminhtml\Catalog\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');
        }

    }



}

app \ etc \ CLR_exportMassAction.xml

app\etc\CLR_exportMassAction.xml

<config>
    <modules>
        <CLR_exportMassAction>
            <active>true</active>
            <codePool>community</codePool>
        </CLR_exportMassAction>
    </modules>
</config>

我只是在寻找一个真正的指针,指示从这里出发的去向.我不确定接下来的故障排除选项是什么.

I am just looking for a pointer really on where to go from here; I am not sure what the next troubleshooting options are.

推荐答案

最有可能的是,本地设置运行在不区分大小写的文件系统上(您在Windows上吗?),而服务器运行在区分大小写的文件系统上文件系统(可能是Linux).

Most likely, your local setup is running on a case-insensitive file system (are you on Windows?), whereas your server is running on a case-sensitive file system (probably Linux).

Magento进行了大量的字符串操作,以将类名转换为文件名等.例如,请参见Varien_Autoload::autoload(),我认为是引起您的问题的原因:

Magento does a lot of string manipulation to convert class names into file names and such. For example, see Varien_Autoload::autoload(), which I presume is causing your problem:

$classFile = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $class)));

如果您插入观察者类(在解析CLR_exportMassAction/observer之后,则是CLR_exportMassAction_Model_Observer),则会得到:

If you plug in your observer class (CLR_exportMassAction_Model_Observer, after resolving CLR_exportMassAction/observer), you get:

str_replace('_', ' ', 'CLR_exportMassAction_Model_Observer')
  = 'CLR exportMassAction Model Observer'

ucwords('CLR exportMassAction Model Observer')
  = 'CLR ExportMassAction Model Observer'

str_replace(' ', DIRECTORY_SEPARATOR, 'CLR ExportMassAction Model Observer')
  = 'CLR/ExportMassAction/Model/Observer'

因此,Magento正在查找名为CLR/ExportMassAction/Model/Observer.php的文件,但您的文件名为CLR/exportMassAction/Model/Observer.php-请参见小写的e?

So, Magento is looking for a file called CLR/ExportMassAction/Model/Observer.php, but your file is called CLR/exportMassAction/Model/Observer.php - see the lower-case e?

也许还有其他一些套管问题,但这是最突出的问题.

There might be some other casing issues as well, but this is the most prominent one.

我建议将模块名称空间从CLR重命名为Clr,将实际模块从exportMassAction重命名为Exportmassaction,并确保所有类名和文件名精确匹配.这是避免Magento出现大小写问题的最简单方法(即使您在同一标识符中包含多个单词).

I recommend renaming your module namespace from CLR to Clr, and your actual module from exportMassAction to Exportmassaction, and making sure that all of your class names and file names match precisely. This is the easiest way to avoid casing issues with Magento (even if you have multiple words in the same identifier).

这篇关于Magento Mass Action,网格不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆