danneh.org

Tag: magento

Enabling Spellchecker in Magento WYSIWYG editor

by Dan on Oct.17, 2012, under Magento

A little bit of a puzzling one, and not appearing to be much information about this, seemingly straight-forward task. Enabling the spellchecker plugin in TinyMCE in Magento’s admin. Here’s how you do it;

In js/mage/adminhtml/wysiwyg/tiny_mce/setup.js, find “theme_advanced_buttons3″, and update it as follows;

theme_advanced_buttons3 : 'tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,ltr,rtl,|,fullscreen,|,spellchecker',

Then find “var plugins” (should be a handful of lines above the one you just changed), and update it as follows (this one tripped me up, as not doing this will simply tell TinyMCE to ignore that “spellchecker” button you just added).

var plugins = 'safari,pagebreak,style,layer,table,advhr,advimage,emotions,iespell,media,searchreplace,contextmenu,paste,directionality,fullscreen,spellchecker,noneditable,visualchars,nonbreaking,xhtmlxtras';

Finally, download PHP Spellchecker from TinyMCE’s website, and extract into js/tiny_mce/plugins/.

Reload the admin, open a WYSIWYG editor, and there it is, at the end of the third line of icons!

1 Comment :, , more...

The start of something great (possibly)..

by Dan on Jul.05, 2012, under Magento, Module Development, PHP

When I first setup this website, it was mainly for my own benefit – a place to note down annoyances, bug fixes, work-arounds for various issues in the tech world. I’d use it to refer back to (or refer other people to) when I’d been asked to help/offer advise on a particular topic that I’d covered previously.

However.

All that seems to have died off now, all the bugs got fixed, and I’m no longer annoyed (LOL -now there’s a dream). So, in order to make it look like this website is still being updated (since I’ve only posted once this year so far!), I’m going to start a series on Magento module development, offering tutorials, how-to’s, tips and tricks, for developing your own Magento modules with. I’ll cover areas such as;

  • The basics
  • Blocks, Models and Helpers in-depth
  • “Mysql4″
  • Using events and observers
  • The administration area
  • Shipping methods
  • Payment gateways

..and much more. Watch this space for what will probably be the most I’ve ever written in a really long time!

I might offer more than Magento tutorials in the future. If you have a particular topic/subject area you’d like me to cover, get in touch¬†and I’ll see what I can do!

-Dan :)

Leave a Comment :, , more...

Get website-level configuration in Magento

by Dan on Dec.07, 2011, under Magento, PHP

I stumbled across this one a couple of times now, and it’s caught me out every time.

With Magento, you have the method Mage::getStoreConfig() to get a store-level config, but nothing obvious to get a website-level configuration (such as a default URL for the website).

So I used this;

Mage::app()->getWebsite($websiteId)->getConfig('web/unsecure/base_url')

It’s the same syntax as what’s used in Mage::getStoreConfig(), but uses getWebsite() instead of getStore(). Hopefully this won’t catch me out anymore!

2 Comments :, , , more...

Bug in Magento 1.6.1.0/1.6.2.0 affecting development sites using base_url

by Dan on Nov.14, 2011, under Magento, PHP

I installed a copy of Magento 1.6.1.0 on a dev site I setup to do some testing with Varnish with (more on that later). However, in the requirement to be able to get to Magento using 2 different URL’s, I stumbled across this quite annoying bug.

a:5:{i:0;s:67:"Illegal scheme supplied, only alphanumeric characters are permitted";i:1;s:729:"#0 /home/dan/workspace/magento1610/app/code/core/Mage/Core/Model/Store.php(712): Zend_Uri::factory('{{base_url}}')
#1 /home/dan/workspace/magento1610/app/code/core/Mage/Core/Controller/Varien/Front.php(313): Mage_Core_Model_Store->isCurrentlySecure()
#2 /home/dan/workspace/magento1610/app/code/core/Mage/Core/Controller/Varien/Front.php(161): Mage_Core_Controller_Varien_Front->_checkBaseUrl(Object(Mage_Core_Controller_Request_Http))
#3 /home/dan/workspace/magento1610/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Controller_Varien_Front->dispatch()
#4 /home/dan/workspace/magento1610/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#5 /home/dan/workspace/magento1610/index.php(80): Mage::run('', 'store')
#6 {main}";s:3:"url";s:85:"/index.php/admin/system_config/edit/section/web/key/41c8c3d3f4bcb72e3c267ae0b73333d7/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

Bug reports on Magento’s site here, here, here and here. Not being patient enough for Varien to fix it, I developed a small extension which resolves the problem. It’s available to download below.

Put the tarball in the Magento webroot and extract. After you install this extension, you’ll need to empty the cache manually (if it was enabled). I assume if you’re reading this, then your Magento installation is broken. To do this, simply remove the contents of var/cache in Magento’s webroot.

When you re-visit your Magento’s front or backend, the problem should vanish.

BTS_1610Fix.tar.gz (md5: 8316468f4e179cf2f512edaaf62a12db)

Updated 9th January 2012: It apparent that, attempting to login before applying this update with {{base_url}} set screws up the admin login cookies somehow. When you apply this patch, you’ll probably need to empty out your chosen browser’s cookie jar before attempting to login. You can tell if you need to or not by trying to login, and Magento coming back to you with a login screen, with no failed login message.

Updated 12th January 2012: Magento 1.6.2.0 was released today. I can confirm that this problem still exists and has not yet been fixed (despite what the developers have written on one of the bug reports).

Updated 25th April 2012: I can confirm that this problem has been resolved in the latest 1.7.0.0 version, released 24th April 2012.

89 Comments :, , , more...

Getting Configurable Product from Simple Product ID in Magento 1.5+

by Dan on Sep.19, 2011, under Magento, PHP

I recently stumbled across a hurdle which stopped some of my code from working. It was code that gets the configurable product associated with a given simple product. Many solutions out there call a “loadParentProductIds()” function within the Mage_Catalog_Model_Product class. However, as of Magento 1.4.2.0, they deprecated this method, simply by setting the data element (and returning) an empty array. So any calls to this function would return/yield no parents. Hm, how to get the parent product now?

Finally, I managed to find a workable solution. Check this out;

$simpleProductId = 465;
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
                  ->getParentIdsByChild($simpleProductId);
$product = Mage::getModel('catalog/product')->load($parentIds[0]);
echo $product->getId(); // ID = 462 (aka, Parent of 465)

There you have it. Short and sweet.

6 Comments :, , more...

Blogroll

A few highly recommended websites...