Solved: Class Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory does not exist

Solved: Class Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory does not exist

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:

chown-ubuntu-terminal

  • 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.

 

Solved: How to reset Magento 2 admin passwords using command line?

Solved: How to reset Magento 2 admin passwords using command line?

desctop-screenshot

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.

  1. Log in to your server with SSH. You can either use Putty or OS Terminal to connect.

    1. Run ssh your-username@hostname/IP
    2. Enter your password when prompted
  2. Navigate to your Magento installation, but replace the bracketed placeholders accordingly:

    cd /[home]/[demo]/[demosite.com]/[html]/

  1. Retrieve the admin user’s information from the database using the below command, but make the following adjustments:

    1. Replace [db_user] with your database user.

    2. Replace [db_name] with your database name.

    3. 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

  1. 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”

  2. hit enter and the password will be updated.

 

Echo template names/file paths like Magento in WordPress

Echo template names/file paths like Magento in WordPress

Just paste the following code in your child theme’s functions.php file and it will display the template paths in wordpress. It is important to note that the path will only be visible to the logged in users so I highly recommend to remove this function from your codebase before deploying the website to LIVE.

 
 // REMOVE - show template name
 add_action('wp_head', 'show_template');
 function show_template() {
 global $template;
 global $current_user;
 get_currentuserinfo();
 if ($current_user->user_level == 10 ) print_r($template);
 }
 // REMOVE - end show template name

(more…)

Solved: Magento2 configurable product is ‘Out of Stock’

Solved: Magento2 configurable product is ‘Out of Stock’

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:

  1. Whilst creating tte product configurations, make sure all configurations have the quantity assigned to them.
  2. 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’
  3. 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.
  4. Once you have updated the stock status of the configurations, clear cache and reindex (Click here to learn how to reindex Magento2) Magento.
  5. Go back to the frontend product page, refresh the website and everything will be back to normal.
Solved: The image cannot be removed as it has been assigned to the other image role in Magento2

Solved: The image cannot be removed as it has been assigned to the other image role in Magento2




The image cannot be removed as it has been assigned to the other image role

Solved: The image cannot be removed as it has been assigned to the other image role in Magento2




I have been using Magento2 for quite a few months now and it’s always good to learn new things and share my experience with other developers.

I recently tried to remove an image from a configurable product and I received an error telling me that ‘The image cannot be removed as it has been assigned to the other image role’, it was an odd message because I was sure that I unset that image and set a new image as base, small and thumbnail, however, something wasn’t still right so I did the following to fix this:




  • Make sure that you are not in the DEFAULT STORE view, if that is the case, please switch to your website store view.
  • Set another image as Base, thumbnail and small image.
  • Now you can easily remove the image.

Please share this post with others if the solution worked for you.