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
@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{
/**
<?php
$elementName = "storecredit_history_listing";
$structure = $this->getStructure();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$contextFactory = $objectManager->get('Magento\Framework\View\Element\UiComponent\ContextFactory');
$uiComponentFactory = $objectManager->get('Magento\Framework\View\Element\UiComponentFactory');
$context = $contextFactory->create(
[
'namespace' => $elementName,
'pageLayout' => $this->getLayout()
<?php
public function formatXmlString($xml) {
// add marker linefeeds to aid the pretty-tokeniser (adds a linefeed between all tag-end boundaries)
$xml = preg_replace('/(>)(<)(\/*)/', "$1\n$2$3", $xml);
// now indent the tags
$token = strtok($xml, "\n");
$result = ''; // holds formatted version as it is built
$pad = 0; // initial indent
@satishgumudavelli
satishgumudavelli / Magento2Cleanup.sh
Last active February 19, 2020 07:05
Magento 2 deployment (cleanup)
echo 'Setting Permissions...'
chmod -R 777 var generated pub;
echo 'Cleaning Junk...'
rm -rf var/cache/* generated/* var/view_preprocessed/* var/page_cache/* pub/static/frontend/;
echo 'Setting Permissions...'
chmod -R 777 var generated pub;
echo 'Running compilation...'
php -dmemory_limit=5G bin/magento setup:di:compile;
echo 'Indexing...'
php -dmemory_limit=5G bin/magento indexer:reindex;
@satishgumudavelli
satishgumudavelli / Magento 2.json
Created January 8, 2020 20:04
VSCode Snippet
{
"Arguements": {
"prefix": "m2.layout.args",
"body": [
"<arguments>",
"\t$0",
"</arguments>"
],
"description": "Includes a certain layout file"
},
@satishgumudavelli
satishgumudavelli / default.vcl
Created January 3, 2020 09:16
Magento 2 VCL Configurations
vcl 4.0;
import std;
# The minimal Varnish version is 4.0 For SSL offloading, pass the following header in your proxy server or load balancer:
# 'X-Forwarded-Proto: https'
backend default {
.host = "127.0.0.1";
.port = "8080";
.first_byte_timeout = 600s;
@satishgumudavelli
satishgumudavelli / lighttpd.conf
Created January 2, 2020 20:34
edit this file : /etc/lighttpd/lighttpd.conf for magento 2 configuration lighttpd
#/etc/lighttpd/lighttpd.conf
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_rewrite",
)
server.document-root = "/var/www/html/"
@satishgumudavelli
satishgumudavelli / import-demo.csv
Last active January 3, 2020 06:50
Magento 2 Product import script
sku store_view_code attribute_set_code product_type categories product_websites name description short_description weight product_online tax_class_name visibility price special_price special_price_from_date special_price_to_date url_key meta_title meta_keywords meta_description base_image base_image_label small_image small_image_label thumbnail_image thumbnail_image_label swatch_image swatch_image_label created_at updated_at new_from_date new_to_date display_product_options_in map_price msrp_price map_enabled gift_message_available custom_design custom_design_from custom_design_to custom_layout_update page_layout product_options_container msrp_display_actual_price_type country_of_manufacture additional_attributes qty out_of_stock_qty use_config_min_qty is_qty_decimal allow_backorders use_config_backorders min_cart_qty use_config_min_sale_qty max_cart_qty use_config_max_sale_qty is_in_stock notify_on_stock_below use_config_notify_stock_qty manage_stock use_config_manage_stock use_config_qty_increments qty_incr
<?php
/**
*
* @author Raj KB<magepsycho@gmail.com>
* @website http://www.magepsycho.com
* @extension MassImporterPro: Pricing - http://www.magepsycho.com/mass-importer-pro-price-importer-regular-special-tier-group.html
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);