by Shoaib Rehman | Apr 21, 2017 | Magento 2, Web development
Steps to reproduce
- Put store in maitenance mode
- Install Magento 2.1 either from CLI or zip upload
- run setup:upgrade and setup:di:compile commands
- Navigate to front end
Expected result
Store page displays normally with catalog navigation for both HTTP and HTTPS requests
Actual result
Store page displays the navigation menu with HTTP request only. It doesn’t work for HTTPS
Solution:
Configure store URL and Varnish on HTTPS so all incoming requests are served securely. Make sure that you update your nginx configuration from fastcgi_param HTTPS $fastcgi_https; to fastcgi_param HTTPS “on”.
by Shoaib Rehman | Feb 8, 2017 | Magento 2
I recently upgraded my Magento installation from Magento 2.0 to Magento 2.1 and everything was fine until I ran ‘php magento setup:di:compile’ command after ‘php magento setup:upgrade’. I was instantly served with a big red error on my SSH tunnel.
After spending hours and hours on trying to fix the issue, I realized that the extension which I created to integrate ZENDESK Chat with Magento 2 contains an outdated Class name. Just so you know – In order to support PHP 7, where “Resource” is a reserved word, Resource namespace was renamed to ResourceModel long time ago. Therefore, it Resource cannot be used as a namespace anymore.
After I fixed the issue, my extension started to work fine and hopefully, you will be able to apply a quick fix by replacing all occurrences of Magento\Sales\Model\Resource\Order to Magento\Sales\Model\ResourceModel\Order
Please leave a comment and let me know if you are still not able to fix the error.
by Shoaib Rehman | Jan 16, 2017 | Magento 2
Magento2 is full of surprises and I am loving and hating it at the same time. I fix one issue and another issue comes up sooner or later.
Mostly, I have been using Ubuntu for Magento 2 development but I decided to try it on Windows to test the platform performance. Installation was nice and easy and I was able to install demo data without any issue.
After setting up the initial version, I decided to create my own extension which involved a few frontend templating. Everything was normal until I ran ‘php bin\magento setup:di:compile’. Screenshot below.
I was served with a fatal error and after scratching my head a few times – and of course hitting on the wall a few times, I decided to remove var/generation directory. It all went fine this time. Alright, so to cut the long store short, do the following:
STEPS:
- Don’t panic
- Take a deep breath
- Remove {magento_directory}/var/generation/
- Run ‘php bin/magento setup:di:compile’ again
Did it fix your issue? Leave a comment below to let others know :)
by Shoaib Rehman | Jan 11, 2017 | Magento 2
Magento 2 generates Factory classes inside var/generation
directory. So, if there is folder permission issue or folder owner issue with that directory then the factory class cannot be generated and you get such error.
When you clear var/generation
directory and set appropriate permission to it then this error should be solved.
T0 update the directory permissions, do the following:
- Open your linux terminal, on Ubuntu you can access it by pressing Ctrl + Alt + T
- On the terminal window, Go to your Apache/Nginx directory e.g. var/www/html/{Magento Directory}
- Type ‘sudo chmod 775 -R {Magento Directory}/’ and hit enter.
- Alternatively, you can apply 777 permission to your {Magento Directory} as well but it is not recommended.
by Shoaib Rehman | Dec 20, 2016 | Magento 2
You must have SSH access to your server in order to use this method. If you do not have SSH access, contact your web host to get one.
-
Log in to your server with SSH. You can either use Putty or OS Terminal to connect.
- Run ssh your-username@hostname/IP
- Enter your password when prompted
-
Navigate to your Magento installation, but replace the bracketed placeholders accordingly:
cd /[home]/[demo]/[demosite.com]/[html]/
-
Retrieve the admin user’s information from the database using the below command, but make the following adjustments:
-
Replace [db_user] with your database user.
-
Replace [db_name] with your database name.
-
Within username=”[admin]'”, replace [admin] with the username requiring the reset. You will be prompted to for the database password before continuing.
echo “select email,firstname,lastname from admin_user where username='[admin]'” | mysql -u [db_user] [db_name] -p
-
To reset the password of a user, execute the following, but replace the bracketed placeholders between the quotation marks with the current user’s information:
php bin/magento admin:user:create –admin-user=”admin” –admin-password=”newpassword” –admin-email=”test@example.com” –admin-firstname=”Test” –admin-lastname=”Test”
- hit enter and the password will be updated.
by Shoaib Rehman | Nov 16, 2016 | Magento 2
Sometimes it happens that you have associated products (Product configurations) in a configurable product but it shows ‘Out of stock’ on front-end despite that you have reindexed your Magento 2 and flushed the system cache as well.
Do the following If you experience the same issues:
- Whilst creating tte product configurations, make sure all configurations have the quantity assigned to them.
- If you do not assign the quantity at this stage then Magento2 will assume that the product is not in stock and it will change the stock status for all configurations to ‘Out of Stock’
- If you did not specify quantity for the configurations then you’d have to do so and change the status of all of the configurations from ‘Out of stock’ to ‘In Stock’ MANUALLY by going to the individual product editor.
- Once you have updated the stock status of the configurations, clear cache and reindex (Click here to learn how to reindex Magento2) Magento.
- Go back to the frontend product page, refresh the website and everything will be back to normal.