Just call:
$payment = $order->getPayment()->getMethodInstance()->getTitle();
Just call:
$payment = $order->getPayment()->getMethodInstance()->getTitle();
This one is quite simple:
$countryName = Mage::getModel(’directory/country’)->load($country_id)->getName();
From time to time previously serialized array will get broken. The most common problem occurs when string length is invalid so instead of
a:2:{i:758;s:4:"test";i:759;s:4:"test";}
you have
a:2:{i:758;s:4:"test";i:759;s:9:"test";}
becouse someone edited something directly in db, in this case to make php unserialize() function to work again, just do this magic:
$data = html_entity_decode($data, ENT_QUOTES, 'UTF-8'); $data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $data ); $data = unserialize($data);
and you will get all strings lenths to be fixed again.
Well, this one can be really painful. But solution is simple, just make sure you are stopping every OpenGL AND sound activity in applicationWillResignActive
function, not in applicationDidEnterBackground
(becouse it’s too late, app is already in background and no OpenGL/Sound is allowed, you can add playing sounds in background into plist but OpenGL won’t be allowed anyway).
It seems to be trivial, but it’s not. If you want to use custom table and custom model, and sort collection by one of your table’s column, you can’t just use addAttributeToSort as you do with native Magento collection (like “catalog/product”). Instead of this, you should use setOrder, so your code should look like this:
$items = Mage::getModel('module/model') ->getCollection() ->setOrder('date_added', 'DESC') ->addFieldToFilter('category_id', array('eq' => $category_id)) ->setPageSize($pageSize) ->setCurPage($currentPage);
Well, that is pretty simple but in case someone will need this, just:
$product = Mage::getModel('catalog/product')->load(123); $inStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getIsInStock();