Magento Widget - 如何确认对块代码的访问?

发布于 2025-01-08 01:06:15 字数 776 浏览 0 评论 0原文

我已经在测试站点上创建了我的第一个 Magento 小部件(与我的实时站点相同的代码和配置)。该小部件在测试站点上完美运行。但是,将代码移至实时站点后,我可以配置小部件实例,但小部件的输出未显示在产品页面上。所以我知道 Magento 正在从小部件的 config.xml 和 widget.xml 文件中提取信息。

我已确认 core_layout_update 表中已插入正确的布局更新。现场系统表上的信息与工作测试站点上的信息完全相同。

我已确认实时站点上的文件权限和所有权是正确的。

我已经确认我可以将另一个(Magento 提供的)小部件放在可配置产品页面(产品额外信息)上的确切位置。所以我知道我的模板等不会妨碍在该位置添加小部件。

我尝试删除小部件实例并重新创建同一小部件​​的新实例。

我已将代码与测试站点进行了比较,并直接从测试站点复制了代码。仍然没有成功。我在 .htaccess 中启用了 php_flag display_errors 并且没有显示错误。启用后,Exception.log 中不会显示任何错误。

实时系统和测试系统位于不同的服务器、不同的操作系统、不同版本的 PHP(均为 5.3.x)上。我已经刷新了所有缓存并确认测试小部件正在显示,因此我认为这不是缓存问题。

确认实时站点上的 Magento 确实可以访问或查找我的小部件的块代码的最佳方法是什么?如前所述,我知道 Magento 正在访问本地代码目录中的 widget.xml 文件。不确定安装 Alan Storm 的 CommerceBug 是否是跟踪或转储 Magento 尝试为相关页面加载的内容(模块、小部件等)的方法。

I have created my first Magento widget on a test site (same code and configuration as my live site). The widget works perfectly on the test site. However, having moved the code to the live site, I can configure the widget instance, but the output of the widget is not showing on the product page. So I know Magento is pulling information from the widget's config.xml and widget.xml files.

I have confirmed that the correct layout update is being inserted in the core_layout_update table. The information on the live system's table is exactly the same as that on the working test site.

I have confirmed that the file permissions and ownership are correct on the live site.

I have confirmed that I can put another (Magento supplied) widget in the exact spot on the configurable product page (Product Extra Info). So I know that my templating, etc. is not getting in the way of adding the widget in that spot.

I've tried deleting the widget instance and recreating a new instance of the same widget.

I have compared the code to the test site and copied the code straight from the test site. Still no success. I have enabled php_flag display_errors in .htaccess and no errors are shown. And no errors are showing in the exception.log when enabled.

The live and test systems are on different servers, different OS's, different versions of PHP (both 5.3.x). I've refreshed all the caches and confirmed that the test widget is showing so I don't think this is a caching issue.

How is the best way to confirm that Magento on the live site can actually access or find the Block code for my widget? As indicated I know Magento is accessing the widget.xml file in my local code directory. Not sure if installing Alan Storm's CommerceBug is the way to trace or dump what Magento is trying to load (modules, widgets, etc) for the page in question.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

静赏你的温柔 2025-01-15 01:06:15

验证您的 xml 位于 /app/etc/modules 文件夹中。

您可以通过进入Admin->System->Configuration->Advanced->Developer来打开块提示,将Current Configuration Scope更改为主网站并单击调试。将模板路径提示更改为并保存。

Verify that you have your xml in the /app/etc/modules folder.

You can turn on Block Hints by going to Admin->System->Configuration->Advanced->Developer, change the Current Configuration Scope to Main Website and click on Debug. Change Template Path Hints to Yes and save.

蓝咒 2025-01-15 01:06:15

验证您的文件名。这已经让我好几次了。我在Mac上开发(不区分大小写),偶尔上传到Linux(区分大小写)时会崩溃。我检查的第一件事就是文件名的大小写。

确保类名与文件名匹配。

Verify your filenames. This has gotten me a number of times. I develop on a Mac (non case-sensitive), and occasionally when I upload to Linux (case-sensitive), it breaks. One of the first thing I check is the file name's case.

Ensure that the class name matches the filename.

苏佲洛 2025-01-15 01:06:15

我要采取的下一步是查看为添加小部件的页面生成的最终页面布局 xml,并确保将一些布局 XML 添加到小部件的页面中。如果不是,则通过小部件 UI 添加到表的布局 XML 更新存在问题。如果是,则开始调试为什么生成的布局 XML 的特定块没有添加到页面中。

这是调试问题的自上而下的方法,但这是我知道的唯一可以确定的方法。

The next step I'd take is to take a look at the final page layout xml generated for the page your'e adding the widget to and ensure a bit of Layout XML is being added to the page for your widget. If it isn't, there's something wrong with the Layout XML Updates that are added to the table via the widget UI. If it is, then start debugging why the particular chunk of generated layout XML isn't being added to the page.

This is the top-down approach to debugging the problem, but it's the only way I know to be sure.

嘴硬脾气大 2025-01-15 01:06:15

我也有同样的问题。这是我的决定:

app\code\local\Mage\Core\Model\Resource\Layout.php

当 'theme' => Mage::getSingleton('core/design_package')->getTheme('layout') 结果不正确:'theme' =>; “multistore”,应该是“主题”=> “你的主题”。
因此,删除函数 getTheme() 中的参数“layout”并获得正确的结果
*/

class Mage_Core_Model_Resource_Layout extends Mage_Core_Model_Resource_Db_Abstract 
{

... 

public function fetchUpdatesByHandle($handle, $params = array())
{
    $bind = array(
        'store_id'  => Mage::app()->getStore()->getId(),
        'area'      => Mage::getSingleton('core/design_package')->getArea(),
        'package'   => Mage::getSingleton('core/design_package')->getPackageName(),  
//      'theme'     => Mage::getSingleton('core/design_package')->getTheme('layout')
        'theme'     => Mage::getSingleton('core/design_package')->getTheme()
    );

    foreach ($params as $key => $value) {
        if (isset($bind[$key])) {
            $bind[$key] = $value;
        }
    }
    $bind['layout_update_handle'] = $handle;
    $result = '';

    $readAdapter = $this->_getReadAdapter();
    if ($readAdapter) {
        $select = $readAdapter->select()
            ->from(array('layout_update' => $this->getMainTable()), array('xml'))
            ->join(array('link'=>$this->getTable('core/layout_link')), 
                    'link.layout_update_id=layout_update.layout_update_id',
                    '')
            ->where('link.store_id IN (0, :store_id)')
            ->where('link.area = :area')
            ->where('link.package = :package')
            ->where('link.theme = :theme')
            ->where('layout_update.handle = :layout_update_handle')
            ->order('layout_update.sort_order ' . Varien_Db_Select::SQL_ASC);
        $result = join('', $readAdapter->fetchCol($select, $bind));
    }
    return $result;
}
}

I had the same problem. It's my decision:

app\code\local\Mage\Core\Model\Resource\Layout.php

When 'theme' => Mage::getSingleton('core/design_package')->getTheme('layout') result is not correct: 'theme' => 'multistore', should be 'theme' => 'your_theme'.
So, delete argument 'layout' in function getTheme() and get right result
*/

class Mage_Core_Model_Resource_Layout extends Mage_Core_Model_Resource_Db_Abstract 
{

... 

public function fetchUpdatesByHandle($handle, $params = array())
{
    $bind = array(
        'store_id'  => Mage::app()->getStore()->getId(),
        'area'      => Mage::getSingleton('core/design_package')->getArea(),
        'package'   => Mage::getSingleton('core/design_package')->getPackageName(),  
//      'theme'     => Mage::getSingleton('core/design_package')->getTheme('layout')
        'theme'     => Mage::getSingleton('core/design_package')->getTheme()
    );

    foreach ($params as $key => $value) {
        if (isset($bind[$key])) {
            $bind[$key] = $value;
        }
    }
    $bind['layout_update_handle'] = $handle;
    $result = '';

    $readAdapter = $this->_getReadAdapter();
    if ($readAdapter) {
        $select = $readAdapter->select()
            ->from(array('layout_update' => $this->getMainTable()), array('xml'))
            ->join(array('link'=>$this->getTable('core/layout_link')), 
                    'link.layout_update_id=layout_update.layout_update_id',
                    '')
            ->where('link.store_id IN (0, :store_id)')
            ->where('link.area = :area')
            ->where('link.package = :package')
            ->where('link.theme = :theme')
            ->where('layout_update.handle = :layout_update_handle')
            ->order('layout_update.sort_order ' . Varien_Db_Select::SQL_ASC);
        $result = join('', $readAdapter->fetchCol($select, $bind));
    }
    return $result;
}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文