Search

Mar 29, 2023

Magento 2 composer commands

Install B2B module

composer require magento/extension-b2b
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:clean

Install sample data M2.3

bin/magento sampledata:deploy
bin/magento setup:upgrade

Upgrade composer form v1 to v2

composer self-update --2
sudo composer self-update 2.1.14

You can go back at any time by using 
composer self-update --1
or 
Use: composer self-update --rollback 

This command allows Composer to rebuild the mapping to project files so that they load faster.

composer dump-autoload -o --apcu

Show Magento version List 

composer show magento/product-enterprise-edition 2.3.* --all | grep -m 1 versions
composer show magento/product-enterprise-edition --all | grep -m 1 versions
composer show magento/magento-cloud-metapackage --all | grep -m 1 versions
composer show mageplaza/magento-2-french-language-pack --all | grep -m 1 versions

Create M2 project

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.1.18 <install-directory-name>

composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition=2.4.0 <install-directory-name>

composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition=2.4.3-p1 <install-directory-name>

composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition=2.4.5-p1 <install-directory-name>

Upgrade M2 

For CE
sudo composer require magento/product-community-edition 2.2.4 --no-update

For EE
sudo composer require magento/product-enterprise-edition 2.4.3-p1 --no-update

For Cloud
sudo composer require magento/product-enterprise-edition 2.4.3-p1 --no-update
sudo composer require "magento/magento-cloud-metapackage":">=2.4.3 <2.4.4" --no-update
sudo composer install

Apply Patch for Adobe Commerce & Magento Open Source

Install the latest quality patches package: ./composer require magento/quality-patches
Apply the patch: ./vendor/bin/magento-patches apply ACSD-45520
Clean the cache: ./bin/magento cache:clean
ACSD-45520: Swatch options not selected on product detail page

Update ece-tools 

sudo composer update magento/ece-tools --with-dependencies
composer require magento/quality-patches

View path in magento version

./vendor/bin/magento-patches status 

Apply individual patches

./vendor/bin/magento-patches apply MAGETWO-XXXX
./vendor/bin/magento-patches apply MAGETWO-XXXX MAGETWO-YYYY

Revert all applied patches:

./vendor/bin/magento-patches revert MAGETWO-XXXX
php ./vendor/bin/ece-patches revert
./vendor/bin/magento-patches revert --all

Add MDVA-ID to Magento Cloud

stage:
  global:
    SCD_ON_DEMAND: true
  deploy:
    MYSQL_USE_SLAVE_CONNECTION: true
    CRON_CONSUMERS_RUNNER:
      cron_run: true
      consumers: []
  build:
    QUALITY_PATCHES:
      - MDVA-34023
      - MDVA-12304
      - MDVA-30232
      - MDVA-28656
      - MDVA-30106
      - MDVA-23764

Magento 2: Discard subsequent rules not working in Catalog Price Rule

Step by step:

0. Create rules:

1. Rule 1: USFlat20
    Apply as fixed amount: 20$
    Priority: 0
    Discard subsequent rules: No

2. Rule 2: USFlat10
    Apply as fixed amount: 10$
    Priority: 1
    Discard subsequent rules: Yes

3. Actual result: 
We've used the 'Discard subsequent rules' feature in Rule 2 but it doesn't seem to work.


CAUSE:

Let's analyze the situation from the screencast you provided:
You have two rules:
    + USFlat20 with priority 0 for -20$ and discard subsequent rules set to No
    + USFlat10 with priority 1 for -10$ and discard subsequent rules set to Yes

The test product is $74.38. Now how rules are applied:
    1. Get the list of rules ordered by priority in ascending order -> 1. USFlat20, 2. USFlat10
    2. Apply discount from the first rule -> USFlat20: 74.38 - 20 = 54.38
    3. Discard subsequent rules? -> No
    4. Apply discount from the second rule -> USFlat10: 54.38 - 10 = 44.38
    5. Discard subsequent rules? -> Yes
    6. End

As you can see the final price is now $44.38 and this is exactly what is visible in the screencast.

Now if we switch priorities for the above rules:
    + USFlat20 with priority 1 for -20$ and discard subsequent rules set to No
    + USFlat10 with priority 0 for -10$ and discard subsequent rules set to Yes

Again test product is $74.38, and rules are applied like this:
    1. Get the list of rules ordered by priority in ascending order -> 1. USFlat10, 2. USFlat20
    2. Apply discount from the first rule -> USFlat10: 74.38 - 10 = 64.38
    3. Discard subsequent rules? -> Yes
    4. End

In such a setup, the final price is $64.38.

This behavior is described in the documentation price-rules-catalog-create