Skip to content

Instantly share code, notes, and snippets.

@martinboy
martinboy / magento2-mixin-on-mixin.md
Last active Sep 21, 2021
Magento 2: Extend mixin with mixin in custom theme
View magento2-mixin-on-mixin.md

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
View gist:d98cac53fdfd1a7176609e9687345be7
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 Apr 1, 2020
Magento: In case when you need to create a custom patch for any code which is in gitignore (for example modules in vendor/ directory)
View magento_patch_files.md
  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 Sep 10, 2018
Magenta 2 snippets: Custom debug log file
View debug_log.xml
<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 Apr 21, 2017
Magento 2 clear order's and customer's data
View m2_clear_order_customer_data.sql
### 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 Jan 21, 2017
Create a directory structure and some files for an ansible role
View ansible-mkrole.sh
#!/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 Apr 29, 2019
Add all symlinks to a .gitignore file that aren't in there already.
View gitignore-symlinks.sh
@martinboy
martinboy / remove_slack_files.py
Last active Jul 14, 2016
Bulk remove files from Slack for the period
View remove_slack_files.py
#
# 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 Jul 11, 2016
Ansible Quickes
View quickies.md