Skip to content

Instantly share code, notes, and snippets.

View gelanivishal's full-sized avatar
🎯
Focusing

Vishal Gelani gelanivishal

🎯
Focusing
View GitHub Profile
@gelanivishal
gelanivishal / delete_customer_attribute.php
Created December 2, 2016 17:19
Delete customer attribute script
<?php
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
umask(0);
Mage::app();
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
@gelanivishal
gelanivishal / create-admin-user.php
Created December 6, 2016 03:34
Create admin user by script
<?php
# Create New admin User programmatically.
require_once('./app/Mage.php');
umask(0);
Mage::app();
try {
$user = Mage::getModel('admin/user')
->setData(array(
'username' => 'developer',
'firstname' => 'developer',
@gelanivishal
gelanivishal / command
Last active February 21, 2017 01:41
Generate static content command
php bin/magento setup:upgrade
rm -rf pub/static/frontend/*
rm -rf pub/static/adminhtml/*
rm -rf var/view_preprocessed/*
php -f bin/magento setup:static-content:deploy
sudo chmod -Rf 777 pub/
sudo chmod -Rf 777 var/
@gelanivishal
gelanivishal / install
Created December 10, 2016 01:44
Install Magento 2 with terminal
php bin/magento setup:install --base-url=http://127.0.0.1/magento211-sample/ --db-host=localhost --db-name=magento211-sample --db-user=root --db-password= --admin-firstname=Magento --admin-lastname=User --admin-email=jaanhaitojahanhai@gmail.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1
@gelanivishal
gelanivishal / unassign_related_product.php
Created December 25, 2016 02:43
M1: Unassign related products
@gelanivishal
gelanivishal / import_reviews.php
Created December 25, 2016 02:54
M1: Import product reviews
<?php
include 'app/Mage.php';
Mage::app();
$customerid = '';
$product_id = '';
$file = fopen("review.csv","r");
$header = null;
@gelanivishal
gelanivishal / export_customer_data_csv.php
Created December 25, 2016 02:55
M1: Export customer data to CSV
<?php
if(php_sapi_name()!=="cli"){
echo "Must be run from the commend line.";
};
/**
* Setup a magento instance so we can run this export from the command line.
*/
require_once('app/Mage.php');
umask(0);
if (!Mage::isInstalled()) {
@gelanivishal
gelanivishal / delete_orders.php
Created December 25, 2016 02:55
M1: Delete all orders
<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::app();
$sql= '
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
@gelanivishal
gelanivishal / steps
Created December 25, 2016 02:56
How to fix the issue: Product images missing in backend but not in frontend
1: Prepare CSV file(update_missing_images.csv) with only one field: sku and upload to the root of Magento installation.
Note: This will contain the sku of those products whose images are missing at the backend.
2: Create a file: update_missing_images.php and upload to the root of magento installation and paste the following code: update_missing_images.php
3: Open your browser and run the following URL: http://your-magento-url/update_missing_images.php
4: That’s all. Try to browse the Images tab, now you will see those missing images.
@gelanivishal
gelanivishal / cleanup_log.php
Created December 25, 2016 02:57
M1: Truncate log tables
<?php
require 'app/Mage.php';
Mage::app();
$xml = simplexml_load_file('./app/etc/local.xml', NULL, LIBXML_NOCDATA);
if(is_object($xml)) {
$db['host'] = $xml->global->resources->default_setup->connection->host;
$db['name'] = $xml->global->resources->default_setup->connection->dbname;
$db['user'] = $xml->global->resources->default_setup->connection->username;