keithg

add new attribute value to product query in magento

We have taken sale attribute to product general tab. $_productCollection = Mage::getResourceModel(‘catalog/product_collection’) ->addAttributeToSelect(‘*’) ->addAttributeToFilter(‘sale’, array(‘eq’ => ‘1’)) ->addMinimalPrice() ->addUrlRewrite() ->addTaxPercents() ->addStoreFilter() ->addFieldToFilter(‘visibility’, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH) ->addFieldToFilter(‘status’, Mage_Catalog_Model_Product_Status::STATUS_ENABLED);     Today s special price query $todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT); $_productCollection = Mage::getResourceModel(‘catalog/product_collection’) ->addAttributeToSelect(‘*’) ->addAttributeToFilter(‘special_price’, array(‘neq’=>”)) ->addAttributeToFilter(‘special_from_date’, array(‘date’ => true, ‘to’ => $todayDate)) ->addAttributeToFilter(‘special_to_date’, array(‘or’=>...Read more …
keithg

Add india timezone in magento

you have to set your timezone manually first go to app/etc/config.xml add your time zone here <general> <locale> <code>en_US</code> <timezone>Asia/Calcutta</timezone> </locale> </general> second go to app/Mage.php on line 768 change this line too date_default_timezone_set(‘UTC’); to your timezone date_default_timezone_set(‘Asia/Calcutta’); ================================================================================= To check Time zone Mage::getModel(‘core/date’)->gmtDate(‘Y-m-d H:i:s’)Read more …
keithg

Google Recaptcha validation with javascript and php

javascript: function validateform(){ var captcha_response = grecaptcha.getResponse(); if(captcha_response.length == 0) { // Captcha is not Passed return false; } else { // Captcha is Passed return true; } } // ]]> PHP if(empty(g-recaptcha-response)) { echo ‘You can not pass the blank captcha code’; }Read more …
keithg

strtr – function in php

strtr — Translate characters or replace substrings $trans = array(“h” => “-“, “hello” => “hi”, “hi” => “hello”); echo strtr(“hi all, I said hello”, $trans); Out Put [crayon-58ab8d3b7679c176980993/]Read more …