1

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.

6
  • From what i see your using layout in order to populate your widget, right ? could you paste bit of code how exactly you do it ? Commented Feb 22, 2012 at 7:47
  • Lrrr - I'm doing nothing special in the code. Using 'CMS -> Widgets' then 'Add New Widget Instance' to create a widget instance. This process allows you to set specific layout criteria such as product type, specific products, block reference and template. The result of this is a record added to the core_layout_update table which is then used by Magento to insert the widget in the normal layout. Commented Feb 22, 2012 at 13:08
  • This widget which you've created is based on one of Magento widget or custom one ? And i presume that you've cleared cache... PS. You can always create your widget in code just to check if can be created. Commented Feb 22, 2012 at 15:12
  • This is a completely custom widget, but I followed examples in the 'Creating a Magento Widget' tutorial (Part 1 and Part 2) and Alan Storm's book 'No Frills Template Layout'. And, yes, I've cleared the cash every way possible. Commented Feb 22, 2012 at 18:27
  • What i would do in your case would be to: 1. Goto CMS > Static Blocks > select static block which is visible in FO 2. Insert to it's content your custom made widget If that doesn't work check apache and magenta logs. Commented Feb 22, 2012 at 19:04

4 Answers 4

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I have not yet turned on block hints because this is a live site, but that will probably be my next effort.
You can put your IP address in the Developer Client Restrictions in the same area. You can put your IP address in Allowed IPs (comma separated) and you'll be the only one who sees the hints. You can go to http://www.whatismyip.com to see your IP address.
1

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.

3 Comments

I've verified the file names. I keep coming back to the fact that this exact same widget code (filenames and all) is working fine on a separate test site. In case it matters I am using a module name that has multiple capitals in it. My module name is 'ShowAttribute' so the path to the module / widget is 'app/code/local/Npe/ShowAttribute'. Again this is working fine on the test site and I've looked at several example of core Magento modules doing the exact same thing. My class names also reflect this same capitalization such as: 'class Npe_ShowAttribute_Block_Sizeandcolor'.
OK. May I ask what OS your test system is using?
My test system is Linux, kernel version 2.6.18-028stab064.7
1

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.

Comments

0

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;
}
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.