Magento2
Power your online business with the most flexible and scalable ecommerce platform
Magento 2 search results relevance with elasticsearch?
Magento 2.3 still use "OR" logic for mysql and elasticsearch. Plus "should" conditions (query to ES) are wrong. That's why relevance almost same. But ES significantly improve performance of search and catalog (layered navigation).
you have to set AND operator in your elastic search json queries, Override the module-elasticsearch/SearchAdapter/Query/Builder/Match.php. file in your custom module and then The code you have to edit in the build function in line no 75
Database backup missing table information "inventory_stock_1" #19542
Database backup missing table information "inventory_stock_1"
The CREATE ALGORITHM statement requires elevated MySQL access.
It is likely that the server you are working on does not have this and will halt the import process.
This line needs to come out of the SQL being migrated.
Instead run the following to create the view
Magento2 Configuration values per deafferent scopes
in order to get any value per specific scope you can use the below parameters
First you need to initialize scopeConfig
* @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $_scopeConfig;
in the constrructer of your class
Get total weight of the cart in Magento2
Get total weight of the cart in Magento2
in order to get the total weight of the cart you can use two main methods, we will list them here
First Method
$weight = {getQuote()}
->getShippingAddress()
->getWeight();
Second method
$items = {getQuote()}->getAllItems(); $weight = 0; foreach($items as $item) { $weight += ($item->getWeight() * $item->getQty()) ; } echo $weight;
Inject reCaptcha in phtml file in Magento 2
the easy way to Inject reCaptcha in phtml file in Magento 2 to add PHP code, use this code to add reCaptcha into newsletter form
How to Get Value of Product Custom Option from Cart & Order in Magento 2
If you are wondering how to get the value of product custom option from cart and order in Magento 2, this is the right place for you to learn that. Published by Mageplaza, this topic will point you how to do that with two examples as the following.
Firstly, you can use ObjectManager:
Get custom options of products present in shopping cart
How to change block's template with alias in Magento2 extension
How to change block's template with alias in Magento2 extension
as we know that some blocks does have alias without name in the xml files, so here we will see how we can change the template for a block with alias instead of name
I will put here an example on how to do it , this was tested in Magento 2.3.4
in the parent module we have this XML
Get the expected Magento2 Product URL Key value
Use CURL library to get token and lists in Magento2
Magento 2 Delete the not used Cart after upgrade Magento
It's very recommanded to delete unused carts after you finish the upgrade using these queries all customers carts that are not converted to order will be deleted
select *
FROM `quote_address`
WHERE `customer_address_id` IS NULL AND `firstname` IS NULL AND `lastname` IS NULL and quote_id in (SELECT entity_id FROM `quote` where is_active= 1)
select * from quote where entity_id not in (select quote_id from quote_address)