Skip to content

Instantly share code, notes, and snippets.

@6ui11em
6ui11em / magento2_reset_user_password.sql
Last active March 18, 2021 11:53
Magento2 reset user password #magento2 #mysql
UPDATE admin_user SET password = CONCAT(SHA2('xxxxxxxYourNewPassword', 256), ':xxxxxxx:1') WHERE username = 'admin';
-- REST Customer & Admin password
SET @pass = '123123q'; -- pone el pass q mas te guste
SET @salt = MD5(UNIX_TIMESTAMP());
UPDATE admin_user SET password = CONCAT(SHA2(CONCAT(@salt, @pass), 256), ':', @salt, ':1');
UPDATE customer_entity SET password_hash= CONCAT(SHA2(CONCAT(@salt, @pass), 256), ':', @salt, ':1');
@6ui11em
6ui11em / magento2_live_templates.xml
Last active December 13, 2017 09:50 — forked from cmuench/magento.xml
Magento2 PHPStorm Live Templates #magento2 #phpstorm #snippets #livetemplates
<template name="magento2:__" value="&lt;?php echo __('$SELECTION$'); ?&gt;" description="Translation" toReformat="false" toShortenFQNames="true">
<context>
<option name="HTML" value="true" />
<option name="PHP" value="true" />
</context>
</template>
<template name="magento2:collection" value="class Collection extends AbstractCollection&#10;{&#10; /**&#10; * Initialize resource model&#10; *&#10; * @return void&#10; */&#10; protected function _construct()&#10; {&#10; $this-&gt;_init($model$::class, $resourceModel$::class);&#10; }&#10;}" toReformat="true" toShortenFQNames="true">
<variable name="model" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="resourceModel" expression="" defaultValue="" alwaysStopAt="true" />
<context>
@6ui11em
6ui11em / php_explode_trim.php
Created December 14, 2017 15:46
PHP explode & trim #php #split #trim
array_map('trim', explode(',', $str));
@6ui11em
6ui11em / magento2_get_store_information.php
Created December 20, 2017 11:34
Magento2 get store information #magento2 #php
<?php
namespace Chapagain\HelloWorld\Block;
class HelloWorld extends \Magento\Framework\View\Element\Template
{
public function __construct(
\Magento\Backend\Block\Template\Context $context,
array $data = []
)
{
parent::__construct($context, $data);
@6ui11em
6ui11em / save_attribute_storeid.php
Created January 24, 2018 09:27
Magento 2 save product attribute in specific store #magento2 #php
// get current store and product store to restore values after save
$currentStore = $this->storeManager->getStore();
$productStore = $product->getStoreId();
// save to desired storeId
$this->storeManager->setCurrentStore($storeId);
$product->setStoreId($storeId);
// you can use also $product->setName ...
$product->setData($attributeCode, $value);
$this->productResource->saveAttribute($product, $attributeCode);
@6ui11em
6ui11em / magento2-mediaqueries.less
Last active January 25, 2018 08:54
Magento 2 media queries #magento2 #php #less #css #responsive
// Common
// (for styles used in both mobile and desktop views)
& when (@media-common = true) {}
// Mobile
// (for all mobile styles.)
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {}
// Tablet
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {}
@6ui11em
6ui11em / breakpoints.js
Created February 22, 2018 21:28
Break points javascript vanilla #js #vanilla #javascript
// https://gomakethings.com/breakpoint-conditional-javascript-in-vanilla-js/
// Define our viewportWidth variable
var viewportWidth;
// Set/update the viewportWidth value
var setViewportWidth = function () {
viewportWidth = window.innerWidth || document.documentElement.clientWidth;
}
@6ui11em
6ui11em / eventlistener.js
Created February 22, 2018 21:31
Event listener javascript vanilla #js #vanilla #javascript
// https://gomakethings.com/why-the-vanilla-js-matches-method-wont-work-with-event-listeners-and-nested-links/
// closest to get element or parents
document.addEventListener('click', function (event) {
// If the clicked element doesn't have the class, bail
if (!event.target.closest('.click-me')) return;
// Otherwise, do whatever...
@6ui11em
6ui11em / arguments.js
Created February 22, 2018 21:33
Arguments javascript vanilla #js #vanilla #javascript
var add = function () {
var total = 0;
for (var i = 0; i < arguments.length; i++) {
total += arguments[i];
}
return total;
@6ui11em
6ui11em / mediaqueris.js
Created February 25, 2018 21:38
Javascript media queries #javascript #js #vanilla #mediaqueries #responsive
if (window.matchMedia('(min-width: 640px)').matches) {
console.log('Wide viewport');
} else {
console.log('Small viewport');
}
if (window.matchMedia('(orientation: portrait)').matches) {
console.log('Portrait');
} else {
console.log('Landscape');