hieunguyen
6/20/2019 - 9:11 AM

Magento 2 development note

Catalog Promo

There is a table which hold all product after promo rule

catalogrule_product_price

The table look like this

product_idrule_price
604287.1

It is a observer of CatalogRule module to get apply the promo price to product data final_price

Magento\CatalogRule\Observer\ProcessFrontFinalPriceObserver

it hooks on the event

catalog_product_get_final_price

Indexer

the builder which reponse for read/write catalogrule_product_price

Magento\CatalogRule\Model\Indexer::applyAllRules

Temporary table generation

temporarily change createTemporaryTable to createTable in

\Magento\Framework\Search\Adapter\Mysql\TemporaryStorage::createTemporaryTable

Checkout note

Magento\Checkout\Model\PaymentInformationManagement::savePaymentInformationAndPlaceOrder

Endpoint for placing order, it performs:

  1. validate the payment method
  2. trigger payment method command
    • authorize

Payment Processing

Magento\Payment\Gateway\Command\GatewayCommand::execute

this method has 1 array parameter which contain:

  • payment (Magento\Payment\Gateway\Data\PaymentDataObject)
    • order (Magento\Payment\Gateway\Data\Order\OrderAdapter)
    • payment (Magento\Sales\Model\Order\Payment)
  • amount (int)

Magento 2 log

file_put_contents(BP . '/var/log/events.log', "$eventName\n", FILE_APPEND);

write array to the log

$arr = ['zzz', 'aaaa'];
file_put_contents('/home/mobelari/public_html/var/log/arr.log', print_r($arr, true), FILE_APPEND);

print trace

$e = new Exception();
$e->getTraceAsString();
file_put_contents(BP . '/var/log/hieu.log', print_r($e->getTraceAsString(), true), FILE_APPEND);