Posts Tagged ‘development’

How to see what fails when you get internal server error in PHP (500 HTTP Error)

31/01/2013

Add this lines as first lines when debugging in maintenance mode:

error_reporting(E_ALL | E_STRICT);

ini_set(‘display_errors’, 1);

 

In Magento you can set developer mode:

Mage::setIsDeveloperMode(true);

 

System.xml and Magento System Configuration

26/01/2013

and

These tags allow you to set end-user facing text for your System Configuration field.

A label appears to the left of your form field, while a comment will appear directly under the field.

A label appears to the left of your form field, while a comment will appear directly under the field.

, ,

These are boolean fields with a value of 1 or 0. They indicate if the field will show up when viewing the System Configuration in the default view, the website view, or the store view.

The implicit assumption is that they also control what options are configurable at each level. However, there???s nothing on the backend enforcing this assumption. That is, a field may be configured to with the following

0

but it will still be possible (although not advisable) to set and retrieve this field???s value at the store level via programatic means.

The is a numerical value that???s used to determine the order of the fields within their group container. The higher the number, the lower the field will sort on the screen.

determines the type of field that will be used to collect the configuration value. Values supported in Magento 1.4 Community Edition are

  1. allowspecific
  2. export
  3. image
  4. import
  5. label
  6. multiselect
  7. obscure
  8. password
  9. select
  10. text
  11. textarea
  12. time

Basic attributes to define your admin fields in your Magento module.

Tip to debug objects in Magento development environment

25/01/2013

Change $_item with the object you want to debug and see methods and attributes:

$var=$_item;echo 'Class '.get_class($var).':';echo ''.implode("() ",get_class_methods($var));foreach($var->getData() as $k=>$v){        echo 'getData(''.$k.'')';}

 

Howto check if Magento core code has been modified

25/01/2013

Your magento is working weird, but there are no third-party extensions actived on the store?

Use standard *nix diff command to compare all current Magento files with corresponding files of default Magento.

$ diff -qrbB cleanmagento/app/code/core shop/app/code/core

Windows tip: Use WinMerge instead

 

Sort Matrix by Name In PHP

24/01/2013

$data = array(    array("firstname" => "Mary", "lastname" => "Johnson", "age" => 25),    array("firstname" => "Amanda", "lastname" => "Miller", "age" => 18),    array("firstname" => "James", "lastname" => "Brown", "age" => 31),    array("firstname" => "Patricia", "lastname" => "Williams", "age" => 7),    array("firstname" => "Michael", "lastname" => "Davis", "age" => 43),    array("firstname" => "Sarah", "lastname" => "Miller", "age" => 24),    array("firstname" => "Patrick", "lastname" => "Miller", "age" => 27)  );function compare_row($a, $b){  return strnatcmp($a['lastname'], $b['lastname']);}// sort alphabetically by nameusort($data , 'compare_row');