Skip to content

Instantly share code, notes, and snippets.

View vasilii-b's full-sized avatar
🙂

Vasilii Burlacu vasilii-b

🙂
View GitHub Profile
@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",
@vasilii-b
vasilii-b / query.sql
Created May 13, 2024 10:57
Magento 2 - get grouped products child count number
select cpe_parent.entity_id as 'Parent ID', cpe_parent.sku as 'Parent Sku', count(cpe_child.entity_id) as 'Child #', cpe_child.sku as 'Child Sku'
from catalog_product_entity cpe_parent
join catalog_product_link cpl on cpe_parent.type_id = 'grouped' and cpl.link_type_id = 3 and cpe_parent.row_id = cpl.product_id
left join catalog_product_entity cpe_child on cpl.linked_product_id = cpe_child.entity_id
group by cpe_parent.sku
order by 'Child #' DESC
@vasilii-b
vasilii-b / namecheap SSL.md
Created June 11, 2023 07:56 — forked from Shourai/namecheap SSL.md
Letsencrypt SSL certificate with namecheap hosting

source: https://savedlog.com/uncategorized/letsencrypt-ssl-certificate-namecheap-hosting/

The “Positive SSL” certificate I bought along with my domain is invalid with any of my subdomains and cannot be used with wildcards. One annoying thing is that namecheap doesn’t offer auto installation of free let’s encrypt certificates, even though, they are saying “Namecheap is dedicated to data security and privacy for all internet users. We believe the movement to encrypt nearly all web traffic is a positive direction. As more sites embrace HTTPS and use of security products, providers of free SSL are beginning to come online.”

Let me show you what it needs to be done in order to “encrypt nearly all web traffic”.

First, not required but it’s helpful to enable ssh access, it is not enabled by default on the base hosting plans, just go an start a live chat and request ssh access.

@vasilii-b
vasilii-b / README.md
Last active March 13, 2023 12:28
Collect Klevu results from JS templating for later usage (send to GA4 for example)

Magepal GA4 <> Klevu Search using JS Templating

The files mentioned in the gist are supposed to be added under a custom theme (app/design/frontend/<vendor>/theme) inside the folder Klevu_Search.

Alternatively, the same could be achieved by having the files (layouts, templates) inside a custom module.

@vasilii-b
vasilii-b / check-db-size.sh
Last active March 3, 2023 07:56
Check database size on disk and see the table sizes with SQL
df -h | grep 'mysql\|Filesystem'
@vasilii-b
vasilii-b / Show database size.sql
Last active November 8, 2022 09:51
Magento 2 - Check database size
SELECT table_schema "Data Base Name",
SUM( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
SUM( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema;