Get all saleable simple products from configurable product

The following function just gets all saleable (if saleable check is enabled in the Magento configuration) child products from a configurable product: /** * Get saleable simple products from configurable parent product * * @var Mage_Catalog_Model_Product_Type_Configurable $oParentProduct * @return array of Mage_Catalog_Model_Product(Mage_Catalog_Model_Product_Type_Simple) */ public function getAllowedProducts($oParentProduct) { $aProducts = []; $bSkipSaleableCheck = Mage::helper(‘catalog/product’)->getSkipSaleableCheck(); $oAllProducts = […]

Remove items from a collection

Sometimes you need to remove items from a collection (products f.e.) after it was loaded. The following example shows how I removed non salable product items from a collection of sibling products. The respective collection have to be inherited from Varien_Data_Collection. <?php public function getSiblingsCollection() { $oCollection = Mage::getModel(‘catalog/product’)->getCollection() ->addFieldToFilter(‘sheldon_articlenbr’, array(‘eq’ => $this->getProduct()->getData(‘sheldon_articlenbr’))) ->addFieldToFilter(‘type_id’, array(‘eq’ => Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)) […]

Multiselect Options Text

To render the text-values of an multiselect in a BE-grid: <?php /** * * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * It is available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * * * @category AskSheldon * @package AskSheldon_Adminhtml * […]

Image resizer

Just a testscript to test the quality of Magento’s image processing: <?php /** * * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * It is available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * * * @category AskSheldon * @package AskSheldon_FeaturedProducts […]

Create your own Backend theme

When developing Magento Backend functionalities, sometimes you need to add own layout files or templates. In these cases it is a good idea to create a new Backend theme under adminhtml and to modify the Magento configuration to lookup layout files and templates in this new theme before searching in the default one. Therefore you have to create […]

Get table or DB size im Megabyte

Sometimes it is really useful to know how large a certain database table has become. With the following SQL statement you get a list of all tables of the currently connected database with their rounded size in MB: SELECT table_name AS “Table”, round(((data_length + index_length) / 1024 / 1024), 2) “Size in MB” FROM information_schema.TABLES […]

Prevent unwanted email delivery

If you have multiple instances of a Magento shop – for example a staging and a production environment – sooner or later you’ll come to the point, where you need to  synchronize the database from live- to stage-system to get realistic production-like application behavior. In this case it is a good idea to prevent the system from sending mails […]

Get stores last order increment ids

This can be done by the following database query: SELECT cs.store_id, csg.name AS group_name, cw.name AS website_name, cs.name AS store_name, increment_last_id AS last_increment_id, entity_type_code AS entity_code FROM eav_entity_store AS ees INNER JOIN eav_entity_type AS eet ON eet.entity_type_id = ees.entity_type_id INNER JOIN core_store AS cs ON cs.store_id = ees.store_id INNER JOIN core_store_group AS csg ON csg.group_id […]