Posts

Jquery how to cause action after image src is changed and loaded

  So I have a script that changes the main image src when a thumbnail is clicked on. This is all good and well, except that occasionally the image doesn't load immediately when it is clicked on. Essentially how do I know when the new image is loaded from the src change. Here is the line of code I have that changes the source: $thumbnail_image_src = $ ( this ). find ( '.thumbnail-image' ). attr ( "data-full" ); Bind a handler to the 'load' event for the img tag ( this JSFiddle )  $ ( this ). find ( '.thumbnail-image' ). each ( function () {    $ ( this ). load ( function () {      alert ( 'image has changed and loaded' );     })     . error ( function () {      alert ( 'image has failed to load' );     }). attr ( 'src' , $ ( this ). attr ( 'data-full' ));   }); These functions will fire at the appropriate events. Enjoy! ...

image fun

http://www.phpied.com/image-fun-with-php-part-2/

Create custom attribute in magento category

HI friends to create custom attribute for product is to easy , but for a category its tricky. For creating attribute in category general tab use this code and create a new file, place it in root folder like http://localhost/magento-1.6.2.0/magento/attribute.php and run it. its All done enjoy:) <?php require_once ( 'app/Mage.php' ); Mage :: app () -> setCurrentStore (Mage :: getModel ( 'core/store' ) -> load (Mage_Core_Model_App :: ADMIN_STORE_ID )); $installer = new Mage_Sales_Model_Mysql4_Setup; $attribute = array ( 'type' => 'int' , 'label' => 'Is Open' , 'input' => 'select' , 'source' => 'eav/entity_attribute_source_boolean' , 'global' => Mage_Catalog_Model_Resource_Eav_Attribute :: SCOPE_GLOBAL , 'visible' => true , 'required' => false , 'user_defined' => true , 'default...

Close fancy box after some time

if you want to close your fancy box pop-up window Automatically after some time then  setTimeout(" parent.jQuery.fancybox.close(); ", 5000); in red portion we can set any thing which works delay after 5 second,

Hyperlink within iframe and open page on parent window not in iframe

If any one give a hyperlink in iframe, then genrally this link opened within iframe , but if you want to open that hyperlink in parent browser window then do this and enjoy :) (helps to handle iframe type fancybox also) ie hyper links which opens in parent window not in iframe. <a class= "fancybox-close" onclick= "parent.document.location='some_url’ ></a>

Display new arrivals by category in Magento

Some times clients demand to show new arrivals product on home page or product listing page in magento store. Then its very easy to show that For this load product collection and apply these filters <?php   /*Find the current date */   $todayDate = Mage :: app () -> getLocale () -> date () -> toString (Varien_Date :: DATETIME_INTERNAL_FORMAT );  /*Making collection of new arrivals*/   $_productCollection = Mage :: getModel ( 'catalog/product' ) -> getCollection () -> addAttributeToSelect ( '*' ) -> setStoreId ( $storeId ) -> addStoreFilter ( $storeId ) -> addCategoryFilter ( $category ) -> addAttributeToFilter ( 'news_from_date' , array ( 'date' => true , 'to' => $todayDate )) -> addAttributeToFilter ( 'news_to_date' , array ( 'or' => array ( 0 => array ...

change precision of price in magento

By default Magento show price with two decimal points like Rs. 25.00 , if you want to change the precision of  Price then In line 62 in /lib/zend/Currency.php you can change the precision for all  prices in your shop. <?php protected $_options = array( 'position' => self::STANDARD, // position for the currency sign 'script' => null, // script for output 'format' => null, // locale for numeric output 'display' => self::NO_SYMBOL, // currency detail to show 'precision' => 0, // precision for currency 'name' => null, // name for this currency 'currency' => null, // 3 lettered international abbreviation 'symbol' => null // currency symbol ); and /app/code/core/Mage/Core/Model/Store.php Change the roundPrice function to: public function ro...