Posts

Showing posts from October, 2012

Randomize Collection In magento

Randomize Collection In magento <?php $_model = Mage :: getModel ( 'catalog/category' ); // Using the "catalog/navigation" Block Classes, we can invoke the getStoreCategories() method to get all Store Cats. $storeId = Mage :: app () -> getStore () -> getId (); $_categories = Mage :: getModel ( 'catalog/category' ) -> getCollection () -> addAttributeToSelect ( '*' ) -> addIsActiveFilter () -> addLevelFilter ( 2 ) -> setStoreId ( $storeId ); $_categories -> getSelect () -> order ( new Zend_Db_Expr( 'RAND()' )); $new = "" ; $new2 = "" ; // We'll loop through the returned Category Object foreach ( $_categories as $_category ) { //this gives random order of products }
 Programming Mistakes Improper Input Validation Ensure that your input is valid. If you're expecting a number, it shouldn't contain letters. Nor should the price of a new car be allowed to be a dollar. Incorrect input validation can lead to vulnerabilities when attackers can modify their inputs in unexpected ways. Many of today's most common vulnerabilities can be eliminated, or at least reduced, with strict input validation. Improper Encoding or Escaping of Output Insufficient output encoding is at the root of most injection-based attacks. An attacker can modify the commands that you intend to send to other components, possibly leading to a complete compromise of your application - not to mention exposing the other components to exploits that the attacker would not be able to launch directly. When your program generates outputs to other components in the form of structured messages such as queries or requests, be sure to separate control information a

Add template exceptions on the basis of parameter magento

copy  this file in magento local Mage before edit. /public_html/app/code/core/Mage/Core/Model/Design/package.php <?php /**  * Magento  *  * NOTICE OF LICENSE  *  * This source file is subject to the Open Software License (OSL 3.0)  * that is bundled with this package in the file LICENSE.txt.  * It is also available through the world-wide-web at this URL:  * http://opensource.org/licenses/osl-3.0.php  * If you did not receive a copy of the license and are unable to  * obtain it through the world-wide-web, please send an email  * to license@magentocommerce.com so we can send you a copy immediately.  *  * DISCLAIMER  *  * Do not edit or add to this file if you wish to upgrade Magento to newer  * versions in the future. If you wish to customize Magento for your  * needs please refer to http://www.magentocommerce.com for more information.  *  * @category    Mage  * @package     Mage_Core  * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentoc