Monday, October 26, 2015

PHP Remove special (non printable) characters from text

 

$mystring = " Fund BDM̢۪s were then able to engage with 19 employers, most of whom were subsequently converted to the MTAA Super Clearinghouse.
";
preg_replace("/[^\x0A\x20-\x7E]/",'', $mystring);

echo $mystring;

//The above code will result in

Fund BDMs were then able to engage with 19 employers, most of whom were subsequently converted to the MTAA Super Clearinghouse..
        

Wednesday, October 21, 2015

DISPLAY OUT OF STOCK PRODUCTS ACCORDING TO ADMIN INVENTORY SETTING

 

$isOutOfStockAllowed = Mage::getStoreConfig('cataloginventory/options/show_out_of_stock');
 
  foreach($_productCollection as $_product)
       {
        if(!$isOutOfStockAllowed){
         if(!$_product->isSaleable()){
          continue;
         }
         
        }
        //PRODUCT DISPLAY CODE HERE
        
        }
        

Saturday, October 17, 2015

Facebook page feed time issue

I was implementing facebook page feed for one of my client, the feeds were appearing correct but time was different, actually it was a timezone issue, you have to convert facebook time to local timezone, and to do this i found the perfect way.

step1.
Download and include the js file into your script.

https://gist.github.com/aredo/4153245

step2:

use below code to determine the client timezone:

<script type="text/javascript">
    jQuery(document).ready(function() {
       var timezone = jstz.determine();
var timezonename = timezone.name();  
    });
</script>