Skip to content

Instantly share code, notes, and snippets.

View denishvachhani's full-sized avatar
🏠
Working from home

Denish denishvachhani

🏠
Working from home
View GitHub Profile
@denishvachhani
denishvachhani / responsive.css
Created November 5, 2015 08:36
Media Query
/* Portrait phones and smaller */
@media (max-width: 480px) { }
/* Landscape phones and portrait tablets */
@media (max-width: 767px) { }
/* Portrait tablets and small desktops */
@media (min-width: 768px) and (max-width: 991px) { }
/* Landscape tablets and medium desktops */
@denishvachhani
denishvachhani / footerphp.js
Last active August 29, 2015 13:57
Wordpress -- Simple Ajax Example
<script type="text/javascript">
jQuery('#ajax-link').click(function($) {
ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
// We'll pass this variable to the PHP function example_ajax_request
var fruit = 'Banana';
// This does the ajax request
jQuery.ajax({
url: ajaxurl,
data: {
'action':'example_ajax_request',
@denishvachhani
denishvachhani / anyphtml.php
Created March 26, 2014 06:31
Display Most Viewed Products In Magneto.
<?php
$storeId = Mage::app()->getStore()->getId();
$products_list = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->setStoreId($storeId)
->addStoreFilter($storeId)
->addViewsCount();
print"<pre>";
foreach ($products_list as $product)
{
@denishvachhani
denishvachhani / checkversion.php
Created March 26, 2014 06:30
How to check Magento Version?
<?php
include_once(‘app/Mage.php’);
Mage::app();
echo Mage::getVersion();
?>
@denishvachhani
denishvachhani / mageissku.php
Last active August 29, 2015 13:57
Magento – How to Check if the SKU is Exist?
<?php
$sku = 'Your Product Sku';
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
if ($id){
echo "SKU {$sku} exists";
}
else{
echo "SKU {$sku} does not exist";
}
?>
@denishvachhani
denishvachhani / removeproduct.sql
Created March 26, 2014 06:23
How to remove all catalog products in Magento?
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
@denishvachhani
denishvachhani / cloudSettings
Last active May 29, 2021 15:20
Deactivate some menu, sub-menu or/and buttons of the admin bar
{"lastUpload":"2021-05-29T15:19:59.018Z","extensionVersion":"v3.4.3"}
@denishvachhani
denishvachhani / function.php
Last active December 20, 2015 08:49
Hide Admin Menus
<?php
add_action('admin_menu', 'remove_menu_items');
if( !function_exists('remove_menu_items') ) :
/**
*
*/
function remove_menu_items() {
global $menu;
$restricted = array(__('Links'), __('Comments'),
@denishvachhani
denishvachhani / function.php
Last active January 27, 2020 16:33
Remove Dashboard Widgets in Wordpress Backend
<?php
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
if( !function_exists('remove_dashboard_widgets') ) :
/**
*
*/
function remove_dashboard_widgets() {
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal'); // Incoming Links
remove_meta_box('dashboard_plugins', 'dashboard', 'normal'); // Plugins
@denishvachhani
denishvachhani / function.php
Last active December 20, 2015 08:49
Hide Dashboard for all except admin WITHOUT PLUGIN !
<?php
function remove_the_dashboard () {
if (current_user_can('level_10')) {
return;
} else {
global $menu, $submenu, $user_ID;
$the_user = new WP_User($user_ID);
reset($menu); $page = key($menu);
while ((__('Dashboard') != $menu[$page][0]) && next($menu))
$page = key($menu);