Magento Widget - How to confirm access to block code? - 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.

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.

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.

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.

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

Related

Prestashop 1.7 Breadcrumb titles

I am trying to edit the breadcrumbs in a custom Prestashop theme that I am making based on the Classic theme in version 1.7.6.8. The website I am working on has Prestashop located in a folder at mydomain.com/shop, so I would like the breadcrumbs to read:
Home / Shop / Products
Where Home links to mydomain.com and Shop goes to mydomain.com/shop.
I have added the link for Home to mydomain.com ok. Now I want to change the default Prestashop breadcrumbs because it currently reads:
Home / Home / Products
The second home goes to the right link (mydomain.com/shop) but I don't know how to change it to read Shop instead of Home. I have found a way to edit the controllers so as to remove the second home link, this would allow me to just add a new link with Shop next to the new Home link that I already added, however this doesn't seem like a very elegant solution and will require altering the script on lots of pages. Surely there must be a better way?
Thanks for any feedback.
Edit: Here is the code from controllers/productController.php
public function getBreadcrumbLinks()
{
/*$breadcrumb = parent::getBreadcrumbLinks();*/
$categoryDefault = new Category($this->product->id_category_default, $this->context->language->id);
foreach ($categoryDefault->getAllParents() as $category) {
if ($category->id_parent != 0 && !$category->is_root_category) {
$breadcrumb['links'][] = $this->getCategoryPath($category);
}
}
if (!$categoryDefault->is_root_category) {
$breadcrumb['links'][] = $this->getCategoryPath($categoryDefault);
}
/*$breadcrumb['links'][] = array(
'title' => $this->product->name,
'url' => $this->context->link->getProductLink($this->product, null, null, null, null, null, (int) $this->getIdProductAttributeByRequest()),
);*/
return $breadcrumb;
}
You can see the two sections I have removed, the first removes the default "Home" link, the second removes the link with the product name that I do not need. Obviously the code goes somewhere to look up the link and matches it to a name, I just don't know where.
I found the answer, you can change the tag from "Home" to "Shop" by altering the files in shoproot/var/cache/prod/translations/catalogue.[your language].php
There are a number of places where "Home" appears in the file, to change the breadcrumb it is around line 6370 in the en-gb version.
EDIT: Here is a better option, from your Prestashop control panel you can go to international, translations, modify translations. From the drop downs select theme translation, the theme you are working on, the language, click modify, search for "home" and then put the translation as "shop". This saves you having to make the change to the cached file if you have to clear the cache from the control panel.

Edit JomSocial Joomla Registration Page & Adding Content

I'm running JomSocial 3.2 on Joomla 3.
I want to add some content to the right side of the registration page.
Some pictures and other contents.
So far, i've been able to get to the "register.index.php" file,
which is the file that displays some of the content in the homepag.
The file is in: "/site_root/components/com_community/templates/default/" folder
but i've not been able to fully edit the whole registration page.
This could be done in many different ways - even without editing any file. Install this extension: http://extensions.joomla.org/extension/advanced-module-manager and when editing module you'll have additional tab called "tasks" There will be field URL, type inside URLs of your registration form. Thanks to this you'll be able to assign modules to registration form.
You could also override for:
ROOT/components/com_community/templates/default/register.index.php
Copy it to:
ROOT/templates/your-template/html/com_community (if you don't have "html" or "com_community" folders, feel free to create them)
Then you may create module position inside file using this code:
$modules = JModuleHelper::getModules( 'reg-positon' );
foreach ($modules as $module) {
$_options = array( 'style' => 'xhtml' );
echo JModuleHelper::renderModule( $module, $_options );
}
Above code creates module position: "reg-positon'. You'll need to type this name manually as it will be not listed on module positions list.
Now you'll need a bit of html to display it on right or left of registration form.

magento static block images disappear intermittently

Magento site home page contains Static blocks(images) and featured products. Some times Static block images disappears and also the featured product section. But that time top menu and footer loads fine. Static block images loads after few minutes without doing anything.I don't have any clue why it happens. Please help me to find out the cause of this issue.
When i ran into this issue before i needed to overwrite the block in question(in my case it was the footer block) and disable caching for that block.
In Mage_Page_Block_Html_Footer(app/code/core/Mage/Page/Block/Html/Footer.php)
protected function _construct()
{
//commented out to disable the caching of the footer block
// $this->addData(array(
// 'cache_lifetime'=> false,
// 'cache_tags' => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)
// ));
}
But http://www.magentocommerce.com/boards/viewthread/47197/ seems like a much better solution.

Magento: No 'Add product' button on back end new order

I've just installed the latest version of Magento 1.8 and everything is great and works perfectly. However, we've just discovered that there is no 'Add product' button on the admin new orders page. Everything else works as before, including:
customers can order from the front end
admin can add a product from the 'last ordered' or 'recently viewed products' from the customer recent activity panel
It therefore seems to be an issue with just this button alone. We've tried the below fixes without any success:
removed theme from our site (revert to default); button still missing
noted a previous bug relating to payment methods in v 1.7; tried copying all payment .phtml files to theme; button still missing
At a loss as to what this could be. All other functions appear to be working. Has anyone got any pointers as to how to resolve this?
This isn't exactly an ideal fix, because it involves changing core functionality, but the "Add Product" backend button is handled in:
app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items.php
What you're looking for specifically is the getButtonsHtml function. Having the same issue after upgrading from 1.6 to 1.9, I changed mine to look like this:
public function getButtonsHtml()
{
$html = '';
// Make buttons to be rendered in opposite order of addition. This makes "Add products" the last one.
$this->_buttons = array_reverse($this->_buttons);
//If the buttons array isn't empty, let it do its thing
if (!empty($this->_buttons))
{
foreach ($this->_buttons as $buttonData) {
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData($buttonData)->toHtml();
}
}
else {
$addButtonData = array(
'label' => Mage::helper('sales')->__('Add Products'),
'onclick' => "order.productGridShow(this)",
'class' => 'add',
);
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData($addButtonData)->toHtml();
}
return $html;
}
It works, but it's really just a hackjob fix. I'm hoping someone more knowledgeable than I can come up with a proper solution.
Edit - Leaving the above answer, but I sussed out my personal problem. I was running a dual install of Magento, and I forgot to change the .htaccess of my Minify library to re-route to the newer install. So it was compiling the old 1.6 JavaScript and using it on my 1.9 install.

Set homepage from theme's layout

I am trying to set a CMS homepage via a theme's local.xml layout update file in the <cms_index_index> node. I swear I've seen functions to change the store configuration temporarily within a layout node (but maybe I dreamt it), but I'm having trouble finding the layout function in classes like Mage_Core_Block_Abstract and its children classes.
For reference, I've checked in Mage_Cms_IndexController and found the function which renders the homepage:
public function indexAction($coreRoute = null)
{
$pageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE);
if (!Mage::helper('cms/page')->renderPage($this, $pageId)) {
$this->_forward('defaultIndex');
}
}
Or, am I doing this completely the wrong way? What would be best practice for a problem like this? I do not want to add a store view for the new theme, as the new theme is for mobile platforms and requires the same settings from the store view. Thanks guys!
This is not possible. The layout configuration is not invoked until after checks occur to see if there is a valid page which has been specified; because these checks fail, the Default router will match and (by default) the application will display the 404 page.

Resources