Skip to content

Instantly share code, notes, and snippets.

View magefast's full-sized avatar
🥶

Alex S magefast

🥶
View GitHub Profile
@magefast
magefast / magento-customer-gender
Last active February 15, 2018 22:00
Magento, Update Gender for customer. Check Firstname and update Gender
<?php
ini_set('max_execution_time', 1000);
require_once dirname(__FILE__) . '/app/Mage.php';
Mage::app();
$customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('firstname');
foreach ($customers as $c) {
if ($c->getData('firstname') == '') {
@magefast
magefast / Get Firstnames for customers, that not has value for Gender
Last active February 15, 2018 22:14
can using for checking before update Gender for customers, in Magento
<pre>
<?php
ini_set('max_execution_time', 1000);
require_once dirname(__FILE__) . '/app/Mage.php';
Mage::app();
$customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('firstname');
foreach ($customers as $c) {
if ($c->getData('firstname') == '') {
@magefast
magefast / gist:d54a790d20b34dcf189a06f8cd4a1bcc
Last active February 15, 2018 22:32
Example of piece of code, that will return 503 error. When error code is 503 and exist param Retry-After - Google will check page via 300 seconds. This need set when updated website, and maintenance mode.
<?php
if (isset($_SERVER['REMOTE_ADDR'])) {
if ($_SERVER['REMOTE_ADDR'] == '1.1.1.1') { // Your IP-addrese
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 300'); //300 seconds
exit;
}
}
@magefast
magefast / gist:f4912bba69eccda56f92705067ea7ce4
Created February 15, 2018 22:37
Magento, check xml with errors
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('time_limit', 1000);
ini_set('max_execution_time', 1000);
ini_set('memory_limit', '1000M');
@magefast
magefast / gist:4498617e9bf02509a2fdebcd7837e8b3
Created February 15, 2018 22:42
Magento, update url-keys in Url-rewrite module
<pre>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('time_limit', 1000);
ini_set('max_execution_time', 1000);
ini_set('memory_limit', '1600M');
require_once './app/Mage.php';
Mage::app();
@magefast
magefast / gist:a26e6f083ae10dfa96df1d9652910fe4
Created February 15, 2018 23:05
Magento, get count of products in Category, products - exist in stock, and with sale price
<pre>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('memory_limit', '1G');
require_once './app/Mage.php';
Mage::app();
@magefast
magefast / gist:b654dd3a4786d3ef28d87eb7ae4ff034
Last active February 15, 2018 23:16
Magento, get list of products that without assigned to any categories
<pre>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('time_limit', 1000);
ini_set('max_execution_time', 1000);
ini_set('memory_limit', '1600M');
require_once './app/Mage.php';
Mage::app();
@magefast
magefast / gist:8d06a00bfac86cf375de855b893dc711
Last active February 15, 2018 23:25
Magento, update Urlrewrite - target_path
<pre>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('time_limit', 1000);
ini_set('max_execution_time', 1000);
ini_set('memory_limit', '1600M');
require_once dirname(__FILE__) . '/app/Mage.php';
Mage::app();
@magefast
magefast / gist:575c1d651edef8084489df887d68af0b
Created February 15, 2018 23:30
Magento, remove categories
<?php
ini_set('memory_limit', '1000M');
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once './app/Mage.php';
Mage::app();
Mage::register('isSecureArea', true);
for ($i = 60000; $i <= 70000; $i++) {
@magefast
magefast / gist:d7210417a3249539ec128f8af71a9e4d
Created February 15, 2018 23:37
Magento, remove attribute of customer model
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
set_time_limit(400);
require 'app/Mage.php';
Mage::app('default');
$attributeCode = 'mobilephone';