This is the blog for getting Idea regarding PHP, Magento, jQuery and JavaScript for Customization.

Wednesday, 16 July 2014

jQuery : Remove space form string using JQUERY

HI, Some time we need to remove the Space from the String,

Here the Code for remove Special Characters and Space between string


var Demo = new String('This :::  is / the Test');
temp =  temp.replace(/[^a-zA-Z 0-9]+/g,'');
console.log(temp.replace(/ +/g, ""));





/*Best Seller base on order */


<?php

$storeId    = Mage::app()->getStore()->getId();

$product = Mage::getResourceModel('reports/product_collection')
            ->addOrderedQty()
            ->addAttributeToSelect(array('name', 'price', 'small_image')) //edit to suit tastes
            ->setStoreId($storeId)
            ->addStoreFilter($storeId)
            ->setOrder('ordered_qty', 'desc'); //best sellers on top

Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($product);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($product);

$count = 0;
foreach($products as $pro)
{
$count++;
if($count <= 3)
echo $pro->getorder_items_name();
}

?>
,

No comments:

Post a Comment