Skip to content

Instantly share code, notes, and snippets.

@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 / 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_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 / php_explode_trim.php
Created December 14, 2017 15:46
PHP explode & trim #php #split #trim
array_map('trim', explode(',', $str));
@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 / 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_disable_https.sql
Created November 28, 2017 12:40
Magento2 disable secure https #magento2 #mysql
update core_config_data set value = 0 where path = 'web/secure/use_in_frontend';
update core_config_data set value = 0 where path = 'web/secure/use_in_adminhtml';
@6ui11em
6ui11em / magento2_change_core_config_data_urls.sql
Created November 28, 2017 12:38
Magento2 change core_config_data urls #magento2 #mysql
UPDATE core_config_data SET value='___YOUR_NEW_URL____' WHERE path LIKE '%base_url%';
@6ui11em
6ui11em / diable_foreig_keys.sql
Created November 28, 2017 11:53
Disable / enable foreig keys #mysql
SET foreign_key_checks = 0;
SET foreign_key_checks = 1;
# GLOBAL DISABLE
SET GLOBAL FOREIGN_KEY_CHECKS=0;
SET GLOBAL FOREIGN_KEY_CHECKS=1;
@6ui11em
6ui11em / magento2_reset_customer_password.sql
Last active March 18, 2021 11:53
Magento2 reset customer password #magento2 #mysql
UPDATE `customer_entity`
SET `password_hash` = CONCAT(SHA2('xxxxxxxxYOURPASSWORD', 256), ':xxxxxxxx:1')
WHERE `entity_id` = 1;
-- 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');