*/5 * * * * php -q /home/checkin/public_html/staging/webservices/cron-job.php
Wednesday, 13 June 2018
Tuesday, 24 April 2018
deny direct access to a folder and file by htaccess
<Files ~ "^.*">
Deny from all
</Files>
<Files ~ "^index\.php|css|js|.*\.png|.*\.jpg|.*\.gif|.*\.JPG|.*\.jpeg">
Allow from all
</Files>
Deny from all
</Files>
<Files ~ "^index\.php|css|js|.*\.png|.*\.jpg|.*\.gif|.*\.JPG|.*\.jpeg">
Allow from all
</Files>
Friday, 23 February 2018
How to redirect on http to https and www to no www
1.) Redirect http to https :-
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
2.) Redirect wwwto no www :-
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
2.) Redirect wwwto no www :-
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]
Wednesday, 12 July 2017
Get city name from latitude longitude in php
function getcityname($latitude,$longitude) // get city name from lat long.
{
$geolocation = $latitude.','.$longitude;
$request = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.$geolocation.'&sensor=false';
$file_contents = file_get_contents($request);
$json_decode = json_decode($file_contents);
if(isset($json_decode->results[0])) {
$response = array();
foreach($json_decode->results[0]->address_components as $addressComponet) {
if(in_array('political', $addressComponet->types)) {
$response[] = $addressComponet->long_name;
}
}
if(isset($response[0])){ $first = $response[0]; } else { $first = 'null'; }
if(isset($response[1])){ $second = $response[1]; } else { $second = 'null'; }
if(isset($response[2])){ $third = $response[2]; } else { $third = 'null'; }
if(isset($response[3])){ $fourth = $response[3]; } else { $fourth = 'null'; }
if(isset($response[4])){ $fifth = $response[4]; } else { $fifth = 'null'; }
if( $first != 'null' && $second != 'null' && $third != 'null' && $fourth != 'null' && $fifth != 'null' ) {
$city = $second;
}
else if ( $first != 'null' && $second != 'null' && $third != 'null' && $fourth != 'null' && $fifth == 'null' ) {
$city = $second;
}
else if ( $first != 'null' && $second != 'null' && $third != 'null' && $fourth == 'null' && $fifth == 'null' ) {
$city = $first;
}
else if ( $first != 'null' && $second != 'null' && $third == 'null' && $fourth == 'null' && $fifth == 'null' ) {
$city = $first;
}
return $city;
}
}
{
$geolocation = $latitude.','.$longitude;
$request = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.$geolocation.'&sensor=false';
$file_contents = file_get_contents($request);
$json_decode = json_decode($file_contents);
if(isset($json_decode->results[0])) {
$response = array();
foreach($json_decode->results[0]->address_components as $addressComponet) {
if(in_array('political', $addressComponet->types)) {
$response[] = $addressComponet->long_name;
}
}
if(isset($response[0])){ $first = $response[0]; } else { $first = 'null'; }
if(isset($response[1])){ $second = $response[1]; } else { $second = 'null'; }
if(isset($response[2])){ $third = $response[2]; } else { $third = 'null'; }
if(isset($response[3])){ $fourth = $response[3]; } else { $fourth = 'null'; }
if(isset($response[4])){ $fifth = $response[4]; } else { $fifth = 'null'; }
if( $first != 'null' && $second != 'null' && $third != 'null' && $fourth != 'null' && $fifth != 'null' ) {
$city = $second;
}
else if ( $first != 'null' && $second != 'null' && $third != 'null' && $fourth != 'null' && $fifth == 'null' ) {
$city = $second;
}
else if ( $first != 'null' && $second != 'null' && $third != 'null' && $fourth == 'null' && $fifth == 'null' ) {
$city = $first;
}
else if ( $first != 'null' && $second != 'null' && $third == 'null' && $fourth == 'null' && $fifth == 'null' ) {
$city = $first;
}
return $city;
}
}
Friday, 26 May 2017
Magento fax field replace with mobile number
Open file app/locale/en_US/Mage_Page.csv
Paste the below code at last line
"Fax","Mobile"
For changes in admin panel Go to admin->system->configuration-> customer configuration
And open the address template tab. Then replace all F (Fax) With M (Mobile) in all tabs
1. Text
2. HTML
3. PDF
4. JavaScript Template
The changes will be work on all order,invoice,shipment history and email all places.
Paste the below code at last line
"Fax","Mobile"
For changes in admin panel Go to admin->system->configuration-> customer configuration
And open the address template tab. Then replace all F (Fax) With M (Mobile) in all tabs
1. Text
2. HTML
3. PDF
4. JavaScript Template
The changes will be work on all order,invoice,shipment history and email all places.
Magento Set reviews limit on product page
Copy /app/code/core/Mage/Review/Block/Product/View/View.php to
/app/code/local/Mage/Review/Block/Product/View.php. with following code :-
Find the function getReviewsCollection() and replce with below function.
public function getReviewsCollection()
{
if (null === $this->_reviewsCollection) {
$this->_reviewsCollection = Mage::getModel('review/review')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->addEntityFilter('product', $this->getProduct()->getId())
->setDateOrder();
$this->_reviewsCollection->getSelect()->limit(5);
}
return $this->_reviewsCollection;
}
/app/code/local/Mage/Review/Block/Product/View.php. with following code :-
Find the function getReviewsCollection() and replce with below function.
public function getReviewsCollection()
{
if (null === $this->_reviewsCollection) {
$this->_reviewsCollection = Mage::getModel('review/review')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->addEntityFilter('product', $this->getProduct()->getId())
->setDateOrder();
$this->_reviewsCollection->getSelect()->limit(5);
}
return $this->_reviewsCollection;
}
Add Payment Method Custom column in admin > sales > order
1.) Copy /app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php to
/app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php.
And replace with this function.
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->join(array('payment'=>'sales/order_payment'),'main_table.entity_id=parent_id','method');
$this->setCollection($collection);
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
// end here //
}
2.) Search the function _prepareColumns() and add below code in this function
$payments = Mage::getSingleton('payment/config')->getActiveMethods();
$methods = array();
foreach ($payments as $paymentCode=>$paymentModel)
{
$paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
$methods[$paymentCode] = $paymentTitle;
}
$this->addColumn('method', array(
'header' => Mage::helper('sales')->__('Payment Method'),
'index' => 'method',
'filter_index' => 'payment.method',
'type' => 'options',
'width' => '70px',
'options' => $methods,
));
// End here
/app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php.
And replace with this function.
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->join(array('payment'=>'sales/order_payment'),'main_table.entity_id=parent_id','method');
$this->setCollection($collection);
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
// end here //
}
2.) Search the function _prepareColumns() and add below code in this function
$payments = Mage::getSingleton('payment/config')->getActiveMethods();
$methods = array();
foreach ($payments as $paymentCode=>$paymentModel)
{
$paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
$methods[$paymentCode] = $paymentTitle;
}
$this->addColumn('method', array(
'header' => Mage::helper('sales')->__('Payment Method'),
'index' => 'method',
'filter_index' => 'payment.method',
'type' => 'options',
'width' => '70px',
'options' => $methods,
));
// End here
Subscribe to:
Posts (Atom)