Skip to content

Instantly share code, notes, and snippets.

View vasilii-b's full-sized avatar
🙂

vasilii vasilii-b

🙂
View GitHub Profile
@vasilii-b
vasilii-b / 01.readme.md
Last active June 2, 2026 09:45
Tests the algolia queue sync performance, running per website only as an option.

algolia-performance-test.sh

Bash script for controlled Algolia full-queue reindex on Magento 2 / Adobe Commerce. Supports optional per-website scoping, safety checks, and timing output.

Requirements

  • bin/n98-magerun2 — DB query access
  • bin/magento — Magento CLI
  • Must run from Magento root directory
@vasilii-b
vasilii-b / cron-and-indexers-state
Last active April 10, 2026 17:51
Magento 2 Watch Tower
#!/usr/bin/env bash
set -o errexit
set -o pipefail
MAGENTO_ROOT="${MAGENTO_ROOT:-.}"
ENV_FILE="$MAGENTO_ROOT/app/etc/env.php"
if [ ! -f "$ENV_FILE" ]; then
echo "ERROR: env.php not found at $ENV_FILE"
#!/usr/bin/env bash
# @see https://www.stepsecurity.io/blog/axios-compromised-on-npm-malicious-versions-drop-remote-access-trojan
set -u
set -o pipefail
target_path="${1:-$PWD}"
compromised_versions=("1.14.1" "0.30.4")
@vasilii-b
vasilii-b / msi-source-item-save-filter-existing-skus.patch
Created May 7, 2025 11:13
Filter out the SKUs that aren't in the catalog when there is request to save the SKUs inventory. #MSI | Magento 2 / Adobe Commerce
--- a/vendor/magento/module-inventory/Model/ResourceModel/SourceItem/SaveMultiple.php 2025-02-27 15:30:53
+++ b/vendor/magento/module-inventory/Model/ResourceModel/SourceItem/SaveMultiple.php 2025-05-07 13:19:48
@@ -135,6 +135,19 @@
$stock[] = $sourceItem->getSourceCode();
}
+ // check if skus are present in catalog_product_entity table
+ // and include into updates only those that are present
+ $existingSkusSelect = $connection->select();
+ $existingSkusSelect->from(
@vasilii-b
vasilii-b / youtube-code-extract.php
Created April 3, 2025 10:56
extract youtube code from URL - PHP
$youTubeUrl = "https://www.youtube.com/embed/ARwGpBTQ3sw?si=FgLPCSCYKF1JiVag";
preg_match('/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/', $youTubeUrl, $matches);
$youTubeCode = $matches[1] ?? null;
var_dump(new DateTime());
var_dump($youTubeCode);
@vasilii-b
vasilii-b / fastly-recv-rule.md
Created October 29, 2024 06:53
Adobe Commerce / Magento 2 Maintenance page with Fastly for specific website

The bellow Fastly recv ACL rule will allow to redirect the users to a custom maintenance page (even a CMS page if you like) for a specific domain.

It will still allow the /media and static content (themes) files to be viewed - which allows to build custom maintenance pages right in the admin area with CMS Pages.

Also, it's taking into account the list of IPs to whitelist from the redirect using the Fastly Edge ACL - in this example the name is maint_allowlist.

This comes in hand when you've got an Adobe Commerce/ Magento 2 instance powering multiple websites. That's because with the

@vasilii-b
vasilii-b / readme.md
Created October 14, 2024 15:48
Adobe Commerce Cloud - find the nodes IPs

I logged into each node on Staging and Production ( 3 nodes each, but might be different for you) and ran the following command to gather the public IP of the node:

curl -4 icanhazip.com
@vasilii-b
vasilii-b / 1.truncate-products-inventory-custom-attributes-url-rewrites-adobe-commerce-magento.md
Last active October 9, 2024 12:47
Adobe Commerce / Magento 2: Remove all products, their inventory and custom product attributes

What is this about

  • Remove all the products from the Adobe Commerce / Magento 2
  • Remove the product's assigned inventory (MSI)
  • Remove the product's custom attributes
  • Remove the URL Rewrites for the products

⚠️ Disclaimer

  • This is only steps executed on certain instance, not take it for granted it will work smooth for you
@vasilii-b
vasilii-b / query.sql
Created September 11, 2024 12:05
Select all (multi)select values for specific product attribute(s)
select ea.attribute_code, eaov.value
from eav_attribute as ea
left join eav_attribute_option as eao on ea.attribute_id = eao.attribute_id
join eav_attribute_option_value eaov on eao.`option_id` = eaov.option_id
where ea.attribute_code like "%_range"
order by ea.attribute_code
@vasilii-b
vasilii-b / find-customer-address-with-wrong-region-id.sql
Last active June 7, 2024 09:03
Magento 2 (adobe commerce) find customers with wrong region ID in the address
select
cae.entity_id as "Address ID",
cae.parent_id as "Customer ID",
c.firstname,
c.lastname,
c.email,
cae.country_id,
cae.city,
cae.postcode,
cae.region as "Current Address Region",