Skip to content

Instantly share code, notes, and snippets.

@mathewjosephh
mathewjosephh / CRUD_Operation.php
Last active November 3, 2016 08:14
Magento : select, insert, update, and delete data
//INSERT DATA
$data = array('title'=>'hello there','content'=>'how are you? i am fine over here.','status'=>1);
$model = Mage::getModel('mynews/mynews')->setData($data);
try {
$insertId = $model->save()->getId();
echo "Data successfully inserted. Insert ID: ".$insertId;
} catch (Exception $e){
echo $e->getMessage();
}
@mathewjosephh
mathewjosephh / gist:47646ed3733e2f0776f9e44c8ea36668
Created June 13, 2016 04:58
Encrypt and decrypt information in Magento. By default, Magento uses MCrypt–Blowfish in ECB-Mode to encrypt Data, initialized with the security key you defined when you installed Magento.
<?php
$encrypted_data = Mage::helper('core')->encrypt('my secret value');
$plain_data = Mage::helper('core')->decrypt($encrypted_data);
?>
@mathewjosephh
mathewjosephh / gist:605048d6bf2ac5e4229b1e2aa85ba844
Created June 10, 2016 12:46
Magento – How to Check if the SKU is Exist?
$sku = 'Your Product Sku';
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
if ($id){
echo "SKU {$sku} exists";
}
else{
echo "SKU {$sku} does not exist";
}
NotePad++ creates a backup file you might find at:
%AppData%/Notepad++/backup
@mathewjosephh
mathewjosephh / View.phtml
Last active June 10, 2016 11:53
Pass data from controller to view in magento
<?php $blas = Mage::getSingleton('Modulename/viewinfo'); ?>
<?php echo $blas->getMsg(); ?>
//Delay execution Jquery
$('#search').keyup($.debounce(function() {
// Will only execute 300ms after the last keypress.
}, 300));
//http://underscorejs.org/
//using underscorejs
var d = _.throttle(ajax,200);
$(document).on('click','.overlay,.overlay-close',d);
function ajax(){
<?php
$myXMLData =
"<?xml version='1.0' encoding='UTF-8'?>
<myxml>
<entry>
<string>actiontypedesc</string>
<string>Registration of google1231.com for 1 year</string>
</entry>
<entry>
<string>unutilisedsellingamount</string>
# Set Slow Query Log
long_query_time = 1
slow_query_log = 1
slow_query_log_file = D:/wamp/logs/slowquery.log
log_queries_not_using_indexes = 1
#Set General Log
general_log = on
general_log_file=D:/wamp/logs/general.log
<script>
var arrayOfObjects = [{"college_name":"B S ABDUR RAHMAN UNIVERSITY","id":"61","college_location":"Chennai, Tamil Nadu","college_picture":"1420719572phpiYtWSt.jpeg","vote":"9","college_hashtag":""},{"college_name":"Bhavan's Vivekananda college","id":"56","college_location":"Hyderabad","college_picture":"Bhavans Vivekananda.jpg","vote":"18","college_hashtag":""},{"college_name":"BMS College of Engineering","id":"44","college_location":"Bangalore","college_picture":"bms.jpg","vote":"3","college_hashtag":""},{"college_name":"College of Engineering Guindy, Anna University","id":"49","college_location":"Chennai, Tamil Nadu","college_picture":"Anna-university.jpg","vote":"4","college_hashtag":""},{"college_name":"D G Vaishnav College","id":"54","college_location":"Chennai, Tamil Nadu","college_picture":"dg-vaishnav-college.jpg","vote":"0","college_hashtag":""},{"college_name":"J. B. Institute of Engineering and Technology","id":"55","college_location":"Hyderabad","college_picture":"images.jpg","vote":"5","c