Force HTTPS for the whole store

Since Magento 1.9.1 you can force HTTPS for the whole shop by adding the following configuration-snipped to /app/etc/config.xml or any module config.xml (own module!!!): <frontend> <secure_url> <all>/</all> </secure_url> </frontend> After cleaning the config cache, Magento should generate secure URLs everywhere. That’s how to force secure URL’s in Magento.

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 […]

Install CMS pages with your module

You can do this as shown in the following example of a Magento data setup script: <?php /* @var $installer Mage_Core_Model_Resource_Setup */ $oInstaller = $this; $oInstaller->startSetup(); $aCmsPages = [ [ ‘title’ => ‘FAQ’, ‘root_template’ => ‘two_columns_left’, ‘meta_keywords’ => ‘FAQ’, ‘meta_description’ => ‘FAQ’, ‘identifier’ => ‘faq’, ‘is_active’ => 1, ‘stores’ => 0, ‘sort_order’ => 0, ‘content_heading’ => […]

Install CMS blocks with your module

You can do this as shown in the following example: <?php /* @var $installer Mage_Core_Model_Resource_Setup */ $oInstaller = $this; $oInstaller->startSetup(); $oCmsBlocks = [ [ ‘title’ => ‘Footer bar for benefits’, ‘identifier’ => ‘footer-bar’, ‘content’ => <<<HTML <ul> <li>Shop Benefit 1</li> <li>Shop Benefit 2</li> <li>Shop Benefit 3</li> <li>Shop Benefit 4</li> <li>Customer Service (D): <a href=”tel:08008828838″ class=”tel”>0800 […]

No category tree in Magento backend

Perhaps you now the problem shown below. The category tree of the products isn’t rendered correctly. That’s because I don’t set level and children_count during import of categories. This little script corrects this for me: UPDATE catalog_category_entity SET level = (SELECT LENGTH(path)-LENGTH(REPLACE(path,’/’,”)) AS tmpl FROM (SELECT * FROM catalog_category_entity) AS table1 WHERE catalog_category_entity.entity_id = table1.entity_id); UPDATE […]