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 / Test.php
Last active December 23, 2021 08:45
magento 2 add video to product programmatically
<?php
namespace Yourcompany\Yourmodule\Controller\Test;
use Magento\Framework\Api\Data\VideoContentInterface;
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
use Magento\Framework\App\Action\Context;
use Magento\ProductVideo\Model\Product\Attribute\Media\ExternalVideoEntryConverter;
use Magento\Store\Model\Store;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\StateException;
@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
@satishgumudavelli
satishgumudavelli / EavAtrributeUpdateHelper.php
Last active March 29, 2021 13:43
You can bulk update attribute for Product, Category, Customer, Customer address
<?php
/**
* Copyright © All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Namespace\Module\Helper;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
@satishgumudavelli
satishgumudavelli / Session.php
Last active March 29, 2021 13:42
To refresh minicart properly after checkout
<?php
namespace Vendor\Module\Rewrite\Magento\Checkout\Model;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteIdMaskFactory;
class Session extends \Magento\Checkout\Model\Session{
/**
$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();
}