To swap editor for crontab on a Ubuntu system, just run
$ select-editor |
To swap editor for crontab on a Ubuntu system, just run
$ select-editor |
To install magento on a fresh server use the following.
When apache complains like this.
To just get the version number
$cat /etc/debian_version 5.0.3 |
Some items (such as string, cloth, fluids etc) can be sold in decimal values.
This example will show how to sell string in meters (price etc) but where the customer can order any length – but at least 30 centimeters.
In admin->catalog make the string as a product and under inventory set “Minimum Qty Allowed in Shopping Cart” to “0.3” and “Qty Uses Decimals” to yes. Set up the price as the price per meter.
Also please make sure that the information about the product states that the any length (over 0,3 m) can be ordered and that the price is per meter.
When the customer adds 2.5678 m in the basket, magento will calculate the correct price and show it to the customer.
Here a code solution to using the SOAP interface in magento. This example will get all products (and plenty of information about each product).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | $time_start = microtime(true); try{ $devClient = new Soapclient('http://192.168.1.61/magento/index.php/api/?wsdl', array('trace'=>1, 'exceptions'=>1)); $devSession = $devClient->login('apiuser', 'apipassword'); $productList = $devClient->call($devSession, 'catalog_product.list'); foreach ($productList as $product){ $theProduct = array(); $theProduct['product'] = $product; $theProduct['attributeSet'] = current($devClient->call($devSession, 'product_attribute_set.list')); $theProduct['info'] = $devClient->call($devSession, 'catalog_product.info', $product['sku']); $theProduct['related'] = $devClient->call($devSession, 'catalog_product_link.list', array('related', $product['sku'])); $theProduct['up_sell'] = $devClient->call($devSession, 'catalog_product_link.list', array('up_sell', $product['sku'])); $theProduct['cross_sell'] = $devClient->call($devSession, 'catalog_product_link.list', array('cross_sell', $product['sku'])); $theProduct['grouped'] = $devClient->call($devSession, 'catalog_product_link.list', array('grouped', $product['sku'])); $theProduct['images'] = $devClient->call($devSession, 'catalog_product_attribute_media.list', $product['sku']); $theProduct['tierprice'] = $devClient->call($devSession, 'product_tier_price.info', $product['sku']); $theProduct['stock'] = $devClient->call($devSession, 'product_stock.list', $product['sku']); $allProducts[] = $theProduct; } echo '$allProducts: <pre>' . print_r($allProducts, true) . '</pre>'; } catch (Exception $e){ echo 'Error on line '. $e->getLine().' in '. $e->getFile() . $e->getMessage(); } $time_end = microtime(true); $time = $time_end - $time_start; echo "<br/><br/>execution time " . $time; |
More info on the SOAP API at Magento wiki
Very quick (&dirty):
1 2 3 4 5 6 7 8 | try{ doStuff(); } catch (Exception $e){ echo 'Error on line '. $e->getLine().' in '. $e->getFile() . $e->getMessage(); //Or if you are working inside an object, you could use. echo 'Error on line '.$this->getLine().' in '.$this->getFile() . $e->getMessage(); } |
Now to catch a specific kind of exception (in this case CustomException), and say woups, but to re-throw all other Exceptions.
1 2 3 4 5 6 7 8 9 10 11 | try{ doStuffThatCanGiveCustomException(); } catch (Exception $e){ //echo get_class($e) . "<br/>"; if (get_class($e) == "CustomException" && $e->getMessage() === "My custom exception message."){ echo "woups"; } else throw $e; } |
To throw a custom exception:
throw new Exception('My exception message'); |
For more informaion about this please check out the php manual
The quick way is to run “lsb_release -a”
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 9.10 Release: 9.10 Codename: karmic |
Or just read the info from /etc/lsb-release
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=9.10 DISTRIB_CODENAME=karmic DISTRIB_DESCRIPTION="Ubuntu 9.10" |
It is also possible to check the file “/etc/issue”
$ cat /etc/issue Ubuntu 9.10 \n \l |
From X check out System->about.
If using sudo gives the error message “unable to resolve host hostname” then one solution is to add the hostname in /etc/hosts
127.0.0.1 hostname.domain.com hostname localhost |
In the admin interface it is possible to alter setting on a “default”, “website” or “store” level.
Whether or not the module is visible [and configurable] in these is controlled by the modules config file (most commonly saved as “etc/system.xml”)
There are some lines that looks like:
<show_in_default>1</show_in_default> <show_in_website>0</show_in_website> <show_in_store>0</show_in_store> |
The variables are fairly self explanatory; 0 is don’t show, 1 is show [I have also seen 2 but I haven’t figured that one out yet]