Category Archive:

How to move magento var and media directories

0

I wanted to move magento’s var and media directories outside of the core code base so I wouldn’t have to put them in version control. It would make updating the live web server much easier since the dynamic content of these two directories could remain in place while a new branch of the code was checked out and put along side it. First I created a directory named “common” along side the magento directory and moved the var and media directories inside this one. On my local setup, I created a new virtual host for this directory and added www.common.localhost in my hosts file.

In index.php, add a parameter to Mage::run() like so

//custom directories
$parentDir = dirname(dirname(__FILE__));
$customDirectories = array(
	'media_dir' => $parentDir . '\common\media',
	'var_dir' => $parentDir . '\common\var'	
);
 
Mage::run($mageRunCode, $mageRunType, $customDirectories);

A full list of directory keys can be found on Alan Storm’s site at http://alanstorm.com/magento_base_directories.

To be able to pull images from the url as before, create a sub domain or another domain pointing to your new var and media directory location. On my local machine, I named mine www.common.localhost. In the core_config_data table of the database, update keys “web/secure/base_media_url” and “web/unsecure/base_media_url” with the url pointing to your new location, such as www.common.localhost/media.

That’s it! This solution works for magento 1.6.2.

Posted in: Magento

Continue Reading

Magento Unknown column ‘price_table_price.attribute_id’ in ‘where clause’

2

I’m new to Magento and this error took me a full day to solve. It would have helped if somebody had the solution on the internet, so I’m going to put it out there to help somebody else. On the catalog search, if you limit the products by price this error would show up Unknown column ‘price_table_price.attribute_id’ in ‘where clause’ . I’m going through upgrading a magento install from 1.3.4.2 to 1.6.2 and the method apply() from /app/code/Mage/Catalog/Model/Layer/Filter/Price.php had been overridden with a local method. At some point magento changed this method and the under workings, so the custom overridden method was out of date. Alter your custom method to better mimic the new version provided by magento to solve the issue.

Posted in: Magento

Continue Reading

Magento Exception with message ‘Warning: include(Mage\xxxx\Helper\Data.php)

0

If you receive this error with Magento Exception with message ‘Warning: include(Mage\xxxx\Helper\Data.php) then it means you’re calling a helper somewhere and the helper’s XML config is missing. For this example, let’s say we have a helper called “custom”. First, ensure you’ve created a class at /app/code/local/Yourcompany/Custom/Helper/Data.php . Inside Data.php, there should be the following class:

<?php
class Yourcompany_Custom_Helper_Data extends Mage_Core_Helper_Abstract{}

Then in the file /app/etc/config.xml OR /app/code/local/Yourcompany/Custom/etc/config.xml, add the below xml:

<global>
	<helpers>
	    <lpcustom>
	        <class>Yourcompany_Custom_Helper</class>
	    </lpcustom>
	</helpers>
  </global>
Posted in: Magento

Continue Reading

Which file is Mage::helper

0

The way to call helper classes and functions is to use the static helper function in the Mage class providing the component name and desired helper class. For example Mage::helper(‘customer’) would return an instance of the class “Mage_Customer_Helper_Data” which is located in app/code/core/Mage/Customer/Helper/Data.php. The choice of helper to be returned can be specified by adding a slash to the helper parameter and naming the class desired. Mage::helper(‘customer/address’) would return an instance of the “Mage_Customer_Helper_Address” located at app/code/core/Mage/Customer/Helper/Address.php.

If you are wondering just what file Mage::helper(’catalog’) relates to as I was wondering (there is no ‘catalog.php’ helper file amongst the helpers in the core catalog module) you can add this code in your block to test:

echo get_class(Mage::helper('catalog'));
//outputs Mage_Catalog_Helper_Data
Posted in: Magento

Continue Reading

Zend Studio debugger doesn’t work on Magento

0

Learning Magento is hard enough and when you’re debugger won’t stop at any breakpoints, that’s enough to take any developer out of his game. I was fortunate to find this blog post http://rocinantesoftware.blogspot.com/2009/06/debugging-magento-vista-xampp-zend.html detailing how to configure various debuggers to work with Magento. Below is how to configure your magento project with Zend Studio for Eclipse.

ZEND STUDIO FOR ECLIPSE
The following assumes that Magento can be reached from http://127.0.0.1/magento
- From the “Run” menu, select “Debug Configurations”
- On the left, right-click on “PHP Web Page” and select “New”
- Name: Magento
- Server Debugger: Zend Debugger
- PHP Server: Click on the “New” link
- Name: Magento Server, URL http://127.0.0.1 (do NOT use localhost – I don’t have notes on this, but I’m sure that I had trouble accessing the admin area using local host, and switching to http://127.0.0.1 fixed the problem).
- Hit next, going to the Server Path Mapping, and “Add”
- Path on Server: the windows path to your magento dir, e.g. C:\Users\Ed\workspace\magento
- Path in Workspace: /magento
- Click Finish
- Now back in the “Debug Configurations” dialog, set file to magento/
- uncheck “Auto Generate (URL)”, and set the path (first part of which is auto-generated) to /magento
- In the “common” tab, click “run” and “debug” for showing in the favorite menus.

Also, for me personally I had to edit the php server and clear out the “Local Web Root” input and on the “path mapping” tab ensure you have one entry – the “path on server” should be the full directory path to your application and the “local path” should be the name of your zend studio project, such as “/magento”.

Posted in: Magento, Zend Studio

Continue Reading