After importing a Magento database, you may encounter the error “Call to a member function extend() on a non-object”. The issue can be related to special system rows in several Magento database tables. The following SQL statements may resolve it…
Adding comments to fields in admin area (Magento 1)
It is possible and helpful to add comments to the Magento admin fields. Take a look at the following picture: To add a field and a comment, open your modules system.xml and add the below XML:
|
1 2 3 4 5 6 7 8 9 |
<some_thing translate="label"> <label>Test</label> <frontend_type>text</frontend_type> <sort_order>0</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <comment>Thats a comment!</comment> <some_thing> |
Removing estimated shipping from cart (Magento 1)
To remove the estimated shipping block from the Magento cart, you have to add the below code, or, if the checkout_cart_index handle already exists, simply add the checkout.cart section to it.
|
1 2 3 4 5 6 7 |
<checkout_cart_index> <reference name="content"> <block name="checkout.cart"> <remove name="checkout.cart.shipping"/> </block> </reference> </checkout_cart_index> |
Getting the shipping address for an order (Magento 1)
Use the following code to get the shipping address of a Magento order:
|
1 |
$address = $order->getShippingAddress(); |
Deleting upsell products directly in the database (Magento 1)
Once saved, upsell products can not be removed again easily. Using the following MySQL script, you can delete Magento upsell products from the database.
|
1 2 3 |
DELETE link.* FROM catalog_product_link AS link LEFT JOIN catalog_product_link_type AS linktype ON (linktype.link_type_id = link.link_type_id) WHERE linktype.code = "up_sell" and product_id = 123; |
Loading a product by id (Magento 1)
Use the following code to load a product by id:
|
1 2 |
$productId = 1234; $product = Mage::getModel('catalog/product')->load($productId); |
Removing “in stock” / “sold out” from the product page using CSS (Magento 1)
Add the following CSS to youe themes CSS file and the “in stock” / “sold out” information will not be shown on the Magento product page.
|
1 2 3 4 |
.availability.in-stock, .availability.out-of-stock { display: none; } |
Removing items from cart programmatically (Magento 1)
Using the following code, you can remove an item from the Magento cart by item id:
|
1 2 3 |
$cartHelper = Mage::helper('checkout/cart'); $cartItemId = 123; $cartHelper->getCart()->removeItem($cartItemId)->save(); |
Setting and getting session values (Magento 1)
Use the below code to set and get Magento session values:
|
1 2 3 4 5 6 |
// set value $value = 123; Mage::getSingleton('core/session')->setValue($value); // get value $value = Mage::getSingleton('core/session')->getValue(); |
Reading request parameters (Magento 1)
The following short snippet is sufficient to read a Magento request parameter:
|
1 2 3 |
// Read the ID request parameter // URL koennte so aussehen: http://www.domain.de/index.php/irgendwas/id/251/ $id = Mage::app()->getRequest()->getParam('id'); |