Skip to content

Instantly share code, notes, and snippets.

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

Satish Gumudavelly satishgumudavelli

🏠
Working from home
View GitHub Profile
<?php
if (defined('STDIN')) {
$_GET['user'] = $argv[1];
// sudo -u www-data -- php pub/autologin.php "Lennon ava"
}
header('Pragma: no-cache');
header('Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate, proxy-revalidate');
header('Expires: Tue, 04 Sep 2012 05:32:29 GMT');
ini_set('display_errors', 1);
<?php
/* Need to add this script and csv in var/shell folder */
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('memory_limit', '5G');
error_reporting(E_ALL);
set_time_limit(0);
<?php
/* Need to add this script and csv in var/shell folder */
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('memory_limit', '5G');
error_reporting(E_ALL);
set_time_limit(0);
@satishgumudavelli
satishgumudavelli / deleteimagebysku.php
Last active July 6, 2022 08:50
Delete media gallary by sku
<?php
/* Need to add this script and csv in var/shell folder */
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('memory_limit', '5G');
error_reporting(E_ALL);
set_time_limit(0);
@satishgumudavelli
satishgumudavelli / DbStorage.php
Created April 7, 2021 16:34
Unique constraint violent issue in Magento2
<?php
/**
* Copyright © All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Mageseller\Utility\Rewrite\Magento\UrlRewrite\Model\Storage;
use Magento\Framework\DB\Select;
#requires:
# 'xprintidle' for inactivity check (in ms)
# 'rand' for generating random number (screen resolution)
# 'xdotool' to move the mouse pointer
#parameters:
# 100000 idle time in ms before executing the mousemove
# 800 / 600: your screen resolution, at at least the moving range for the mouse pointer
while :; do
$html .= <<<EndHTML
<script>
require(['prototype'], function(){
Event.observe($('carriers_tablerate_condition_name'), 'change', checkConditionName.bind(this));
function checkConditionName(event)
{
var conditionNameElement = Event.element(event);
if (conditionNameElement && conditionNameElement.id) {
$('time_condition').value = '_' + conditionNameElement.value + '/' + Math.random();
}
<?php $productVideos = []; ?>
<script>
var videoData = JSON.parse('<?= str_replace(["\\"], ["\\\\"], json_encode($productVideos)) ?>');
</script>
@satishgumudavelli
satishgumudavelli / getEavAttributeDataWithoutLoad.php
Created December 11, 2020 19:13
For getting eav attribute raw value
<?php
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Framework\App\Bootstrap;
use Magento\Framework\DataObject;
require '../app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
@satishgumudavelli
satishgumudavelli / CategoryHelper.php
Created December 5, 2020 19:17
Magento 2 get category collection with product count
<?php
namespace Namespacename\Modulename\Helper;
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\Helper\AbstractHelper;
class CategoryHelper extends AbstractHelper
{
/**
* @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory