E-commerce Platforms
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)
Notice: Undefined offset: 2 in Encryptor.php
Error : Notice: Undefined offset: 2 in vendor\magento\framework \Encryption\Encryptor.php
Some time you will have the below error after you move Magento2 from server to another server with different PHP version or even with the same PHP version , now what is the first solution we can do
mostly this library will be missed
php-sodium
So we need to install it , below is some command we can do to install it on Centos
Magento 2: Change Customer Password programmatically
Most programmer need to change sometime the password of one customer programmatically, in this wiki I will give you a code to change the password programmatically
Magento2 add symlink to the media folder to not let it be inside the root
ln -s /real/path/to/media /path/where/you/want/symlink/media
How Magento2 format the product URL
I have looked at almost 100 articles to know how Magento format the URL without any success and finally I found it and it was really so easy , here is the quick way to see it using object manager
Note: please consider to use the dependency injection
$_productloader = $objectManager->get('\Magento\Catalog\Model\ProductFactory'); $product = $_productloader->create()->load(1); echo $product->formatUrlKey({Your text here});
in this way Magento will give you the correct URL which will be used
How do you add translation for extensions in Magento2?
How do you add translation for extensions in Magento2?
Then generate the dictionary with magento shell tool; from :
php bin/magento i18n:collect-phrases -o app/code/{Vendor}/{Module}/i18n/en_US.csv app/code/{Vendor}/{Module}/
do not forget to replace {Vendor} and {Module} with your correct information
get all Observer in Magento2 for specific event
the easy way is to go to this file
\vendor\magento\framework\Event\Manager.php
then go to this function dispatch
you can now user this
foreach ($this->_eventConfig->getObservers($eventName) as $observerConfig) { if ($eventName == "catalog_product_save_after") { $all_observers = print_r($observerConfig, true); } }
Magento 2 correct permissions
The most frequent question, asked by Magento users, is correct permissions. They can differ, whether you run your store in one-user mode, or many-user, and also can be different for different modes.
Single user mode
One-user mode is the simplest case. In this case user shall belong to group, which own Magento system and also runs web-server. For them the following rules apply: