PHP SOLUTIONS

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();
}

?>
,

Wednesday 9 July 2014

Magento : Add Meta Title field in CMS pages

In this Blog I written about to set the Meta title field inside the CMS Page.

Here, Some steps need to follow for Meta Title Field

1) Open File Meta.php

   Location = /app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php

2) Copy - Paste this code after

    $fieldset = $form->addFieldset('meta_fieldset', array('legend' => Mage::helper('cms')->__('Meta Data'), 'class' => 'fieldset-wide'));

    /*Copy*/

    $fieldset->addField('meta_title', 'text', array(
            'name' => 'meta_title',
            'label' => Mage::helper('cms')->__('Title),
            'title' => Mage::helper('cms')->__('Meta Title'),
            'disabled'  => $isElementDisabled
        ));

3)  Open Database - Go to table - cms_page

4)  write this query

     ALTER TABLE `cms_page` ADD `meta_title` VARCHAR(100) NOT NULL AFTER `root_template`;


Now, Check any CMS page in admin side !!