Skip to content

Instantly share code, notes, and snippets.

View martinboy's full-sized avatar

Alexander Martinkevich Martinboy martinboy

View GitHub Profile
@martinboy
martinboy / magento2-mixin-on-mixin.md
Last active September 5, 2023 12:30
Magento 2: Extend mixin with mixin in custom theme

Input data

  • initial widget Magento_Theme/js/view/breadcrumbs (vendor/magento/module-theme/view/frontend/web/js/view/breadcrumbs.js)
  • native mixin that extends this widget: Magento_Catalog/js/product/breadcrumbs (vendor/magento/module-catalog/view/frontend/web/js/product/breadcrumbs.js)

Task

Extend methods of the mixin Magento_Catalog/js/product/breadcrumbs

Solution

  • Declare your mixin in custom theme app/design/frontend/[Vendor]/[theme]/Magento_Catalog/requirejs-config.js file and associate it with the initial widget
I have just discovered a great feature of composer:
composer update --lock
It saves a lot of time when you merge branches with composer.lock file changes in both branches.
Just resolve conflict by applying --ours version of the file (or --theirs, it really doesn't matter) and then run
`composer update --lock `.
Composer will do all the dirty work for you and update composer.lock file according to composer.json changes
and install new packages. The rest of packages in composer are not changed.
@martinboy
martinboy / magento_patch_files.md
Last active April 1, 2020 13:35
Magento: In case when you need to create a custom patch for any code which is in gitignore (for example modules in vendor/ directory)
  1. cd <magento_root>
  2. mkdir -p m2-hotfixes/tmp
  3. Copy original files
    cp --parents <path/to/yout/file1> <path/to/yout/file2> ... m2-hotfixes/tmp
    OR
    rsync -R <path/to/yout/file1> <path/to/yout/file2> ... m2-hotfixes/tmp
  4. cd m2-hotfixes/tmp
  5. git init && git add . && git commit -m "Initial commit"
  6. Make changes in files in m2-hotfixes/tmp directory
  7. git add . &amp;&amp; git commit -m "Fix something"
@martinboy
martinboy / debug_log.xml
Created September 10, 2018 11:47
Magenta 2 snippets: Custom debug log file
<virtualType name="VirtualDebug" type="Magento\Framework\Logger\Handler\Base">
<arguments>
<argument name="fileName" xsi:type="string">/var/log/custom_error.log</argument>
</arguments>
</virtualType>
<virtualType name="VirtualLogger" type="Magento\Framework\Logger\Monolog">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="debug" xsi:type="object">VirtualDebug</item>
</argument>
@martinboy
martinboy / m2_clear_order_customer_data.sql
Created April 21, 2017 13:12
Magento 2 clear order's and customer's data
### QUOTE ###
DELETE FROM `quote`;
DELETE a1
FROM `quote_id_mask` a1
LEFT JOIN quote a2 ON a1.quote_id = a2.entity_id
WHERE a2.entity_id IS NULL ;
DELETE a1
FROM `quote_address` a1
@martinboy
martinboy / ansible-mkrole.sh
Created January 21, 2017 10:17
Create a directory structure and some files for an ansible role
#!/bin/sh
# Create a directory structure and some files
# for an ansible role
# Defaults
DEFAULT_ROLE_PATH=.
# Check input params
if [ -z "$1" ]; then
echo "Missing argument role name"
@martinboy
martinboy / gitignore-symlinks.sh
Last active December 9, 2022 20:37
Add all symlinks to a .gitignore file that aren't in there already.
@martinboy
martinboy / remove_slack_files.py
Last active July 14, 2016 12:28
Bulk remove files from Slack for the period
#
# source https://www.shiftedup.com/2014/11/13/how-to-bulk-remove-files-from-slack
#
import requests
import json
import calendar
from datetime import datetime, timedelta
### Input vars ###
@martinboy
martinboy / quickies.md
Last active July 11, 2016 12:39
Ansible Quickes