Showing posts with label magento. Show all posts
Showing posts with label magento. Show all posts

Sort By Ratings on Product Listing of Magento

Ever wondered what does your customers do to find the best and product from your catalog containing hundreds or thousands of products. 
Well, as a customer purchasing online rely more on the recommendations of other customers. 
Magento provides reviews and ratings module out of the box. Your customers can leave reviews and ratings for the products based on different criteria. These reviews can be useful to you for making the product as per the customer's expectations.
But, by publishing the reviews and ratings also helps the other customers  also to decide the purchase. When there are multiple similar kind of products in your catalog, the ratings will be even more important and useful for the customers.
Magento provides flexibility to sort the products by different attributes, however, sorting by ratings is missing.
Along with full use of review and ratings module, you should consider providing sorting by ratings and rich snippets of reviews.

If you are running your store on the Magento version 1, following product sorting extension for Magento 1 can be useful which is affordable from price point of view.
For the merchants who are running their store on Magento 2 platform, the product sorting extension is available here.

Sort By Discount for Magento Product Listing

So, you have just launched your cool webshop using the powerful Magento platform version 2.x. And now you want to attract customers by raining discounts to your new webstore running on Magento platform. 

Price of some products may be slashed using Magento's out of the box powerful features - Catalog price rules or special prices.

What if your customers see the heavily discounted products scattered on the listing/category page. 

What if your customers want to know which product in particular category or search result is offering the highest discount.

For making your customers feel cool, the sorting option to products by 'Heavily Discounted' is must. So, how can you offer this sorting option to your customers easily and quickly on the webshop running on the powerful Magento platform.

Well, there is an extension which offers this feature along with many other useful sorting options from customers' perspective.
If your store is running on Magento 2 platform, download the Product Sorting extension for Magento 2 and offer your customers the cool sorting options in no time to increase the conversion rate by putting the sought product ahead on category or search results pages.

Direct links to download the Sorting by New products, Popular products, Best seller products, top-rated products and most reviewed products for Magento software are below.

Easiest & Quick to Install Magento 2

Are you use to install Magento 2 software frequently in local environment to develop/test integrations and extensions? Are you tired of installing Magento 2 software frequently and interactions required in the web installer?

Magento 2 provides command line installation tool which takes all parameters at once and installs Magento 2 software without any further intervention of user. Sounds cool! So, below is the command to install Magento 2 software quickly and easily.

php bin\magento setup:install --base-url=http://127.0.0.1/magento2/ --db-host=YOUR_DB_HOST --db-name=YOUR_DB_NAME --db-user=YOUR_DB_USER --db-password=YOUR_DB_PASSWORD --admin-firstname=YOUR_ADMIN_FIRST_NAME --admin-lastname=YOUR_ADMIN_LAST_NAME --admin-email=YOUR_ADMIN_EMAIL --admin-user=YOUR_ADMIN_USERNAME --admin-password=YOUR_ADMIN_PASSWORD --language=en_US --currency=USD --timezone=America/Chicago --cleanup-database --sales-order-increment-prefix="ORD$" --session-save=files --use-rewrites=1 --use-sample-data

Replace the parameter values with your environment values and run the command in the directory where Magento 2 installation files reside.

Magento - SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry


In Magento, the error  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1246-0-2-572' for key 'PRIMARY' comes often when the catalog grows at some extent, say more than 5K SKUs and the server is not configured well OR has low resource availability. 
The server sometimes stops working because of high traffic or whatever reason and at the same time admin tries to save product.

The most possible reason is when you were about to save a product the server might stopped working due to some reason and the database transactions were not committed entirely.
So some data in the database are not matching OR the data saved but the autoincrement was not settled.

Solution:
In the error the entry string can narrow down the debugging. Here in the error the string is '1246-0-2-572'. So, 1246 gonna be the entity ID of the erroneous product.

Step 1: Find the product with ID 1246 and open it. Press all the tabs on the product information form to make the information available in future.

Step 2: In a new browser tab / window delete the product with ID 1246.

Step 3: Re-index all the indices.

Step 4: 'Add Product' with the information which was left open during Step 1.

The error should be resolved. If you're still getting the error try to follow the steps again, but exclude the Upsell, Cross sell, Custom Options and Associated Products information. Repeatedly doing this you could find the exact sub-entity of the product which causes the error. 

There may be other reasons, too, which cause the error. For the error which contains four key entries (here 1246-0-2-572 : SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1246-0-2-572' for key 'PRIMARY) in the error log is most probably related with the Price index.

Magento - Attribute groups (product tabs) missing on product add/edit page

Problem Symptoms:
In Magento admin panel, the product add/edit page do not show all the tabs, i.e. Attribute groups (product tabs) missing on product add/edit page. The tabs which are missing are, actually, there in the corresponding attribute set as attribute groups.

Solution:
Browse your Magento database and look into the eav_entity_type table and find out the entity_type_id for catalog_product entity_type_code. (It may be 4 or 10)
Create database backup.
Open up query editor, generally PhpMyAdmin and run below query.
Replace the entity_type_id value in the query with the one which you got from eav_entity_type table. Also, change the table name eav_entity_type if you have table prefix.

UPDATE eav_entity_type SET additional_attribute_table = 'catalog/eav_attribute',
entity_attribute_collection = 'catalog/product_attribute_collection' WHERE entity_type_id = YOUR_ENTITY_TYPE_ID_VALUE;

Magento - set a cron job in cPanel

Cron job is very handy to do periodic tasks. Magento comes with a very good logic of cron job. Modules of Magento can scheduled different jobs on different times. It is very simple, too.
There is a master cron which handles all the cron models of Magento. It is cron.php.
It can be run from command line which is more better than GET command. 
Magento's cron job is recommend to be run every 5 minutes (5/* * * * *).

Below is a statement which should be settled to run Magento's cron jobs.

/bin/sh /FULL_ABSOLUTE_PATH_TO_MAGENTO_ROOT_DIR/cron.sh & > /dev/null

Programmatically Assign Products from one category to other category in Magento


Programmatically Assign Products from one category to other category in Magento

Create a PHP script file in root directory of Magento directory structure and put below code in it.
Adjust category from ID and to ID according to need.
Execute script.
 To
//  5 => 10
$from = 5;
$to = 10;
 
$category = Mage::getModel('catalog/category')->load($from); 
 
$productCollection = $category->setStoreId(1)->getProductCollection();
 
foreach($productCollection as $_product) {
  $product = Mage::getModel('catalog/product')->load($_product->getId());
 
  $newCategories = $origCats = $product->getCategoryIds();
  if(!in_array($to, $origCats)) {
    $newCategories = array_merge($origCats, array($to));
    $product->setCategoryIds($newCategories)->save();
    echo 'Assigned -- ' . $product->getId() . '
'; } } echo 'Completed Execution!!!'; ?>

Categories of store other than running store in Magento


Sometimes there is need to display categories of store other than running store in Magento.

Below code will achieve it to get categories of store other than running store.

getStore($storeId)->getRootCategoryId();
 
$category_model = Mage::getModel('catalog/category');
 
$_category = $category_model->load($root_cat); // category id for which the child categories to be found
$all_child_categories = $category_model->getResource()->getAllChildren($_category); //array consisting of all child categories id
echo '
';
print_r($all_child_categories);
echo '
'; ?>

Magento Google Checkout Problem - cart just reloads

If anybody is facing Magento Google checkout problem of unnecessary reloading of cart there is strong indication that the cart template file(s) is tempered for some need - most basically design need.

The cart reload problem is caused due to form submission on Google checkout button.

To overcome it, you need to bring the checkout button out of any form on cart page. From browser output first investigate if the button is falling inside some form on cart page, then do some html modifications to bring the Google checkout button out of the form.
This will solve Magento Google checkout problem.

Magento Import Export FAQ

Some FAQ while exporting or importing catalog in Magento

1.) My export script just shows blank page .. it looks like its working but never gets past the "Warning: Please don't close window during importing/exporting data" line in the yellow box.

A: this is a restriction of your webserver. Check the .htaccess file for a line .. set it to php_value max_execution_time 28000. Also check your php log file for errors if you dont allow the error to print out. Possible CRON JOB Extension http://www.magentocommerce.com/extension/2268/cron-profiles

2.) My import works fine except for the fact the QTY is blank.. what should i do?

A: this is cause by 2 things. Either you've editied the file in excel and the CSV is no longer in the proper format or you are using a CSV file with columns in the wrong order. Refer to the sample CSV provided and make sure your QTY is in the same order or if you insist on using a custom csv that isnt support atleast try moving the qty field to the front of the file csv the end of the rows.

3.) Error upon running the profile: Declared adapter catalog/convert_adapter_productimport not found

File is in: "/public_html/app/code/local/Mage/Catalog/Model/Convert/Adapter/Productimport.php " A: Set permissions on that file, improper or insufficient permissions will cause that error.

4.) i am getting this error or one very similar Notice: unserialize() [function.unserialize]: Error at offset 802 of 923 bytes in /home/adultmed/public_html/app/code/core/Mage/Dataflow/Model/Batch/Abstract.php on line 66

A: save your csv in UTF8 format. This will solve the problem.

4.) What do i do when it imports correctly with no errors but they don't display on the site until i reedit and save them??

A: its because your missing the options_container column from your csv and related values. These are required and its recommended not to remove or change columns or remove them

Magento - Products are not showing up in frontend

Below are the basic things to check when your products are not showing up in frontend

  • Are the products Enabled?
Set "Status" of the product "Enabled"
  • Are the products Visible?
If the product can be sale individually, set it's "Visibility" attribute to "Catalog" OR "Catalog, Search"
  • Are the products In Stock?
Set "Stock Availability" of the product "In Stock"
  • Is Product in sufficient quantity to sell?
Set "Quantity" of the product to some integer greater than 0
  • Are any associated products in stock?
If the product is of type complex, like a bundled or configurable product, at least one of the associated products that comprise it must be in stock and enabled 
  • Are the products in the desired category?
  • Are your Caches and Indices out of date?
Access System -> Cache Management and System -> Index Management menus. Re-index all the indices and Refresh all the caches.

Magento - problem after SSL certificate - admin controller issue


Synopsis:
After installing SSL certificate the front controller of a module starts using https, but it is not designed to use secure URLs.

Cause of the problem:
The module is using two controllers, one for front end and the other is for admin.
Name of the front controller and admin controller are same.

When SSL is installed admin panel is secured with https protocol.
Admin controller has higher precedence than front controller.
So whenever a request is made in front end, admin controller of the module is dispatched first and as SSL is installed it will be redirected with https protocol.

How to resolve:
For a quick fix, change admin controller's frontname.
If your admin controller config was
    <admin>
        <routers>
            <example>
                <use>admin</use>
                <args>
                    <module>Namespace_Example</module>
                    <frontName>example</frontName>
                </args>
            </example>
        </routers>
    </admin>
Change it to
    <admin>
        <routers>
            <exampleadmin>
                <use>admin</use>
                <args>
                    <module>Namespace_Example</module>
                    <frontName>exampleadmin</frontName>
                </args>
            </exampleadmin>
        </routers>
    </admin>

Do not forget to change action url of menus in admin.
Your action URL for admin menu may before
<action>example/adminhtml_example</action>
change it to
<action>exampleadmin/adminhtml_example</action>

Finally do not forget to update layout handles.
may before
<example_adminhtml_CONTROLLER_index>
change to
<exampleadmin_adminhtml_CONTROLLER_index>

How to avoid this glitch in future?
As prevention is better than cure, one should not use admin controller, instead use adminhtml controller.

How to run a dataflow profile using external script


Put below PHP script in your magento site's root directory.
<?php

$profileId = 1; // Enter the export profile number from System > Import/Export > Profiles

require_once('app/Mage.php');
umask(0);
Mage::app('admin');

$profile = Mage::getModel('dataflow/profile');
$userModel = Mage::getModel('admin/user');
$userModel->setUserId(0);
Mage::getSingleton('admin/session')->setUser($userModel);
$profile->load($profileId);
if (!$profile->getId()) {
Mage::getSingleton('adminhtml/session')->addError('ERROR: Incorrect profile id');
}

Mage::register('current_convert_profile', $profile);
$profile->run();

echo "EXPORT COMPLETE.\n";
?>

Now access this script http://YOUR_SITE/FILENAME_YOU_GIVEN_TO_ABOVE_SCRIPT

Magento - Index Management shows the 'Category Flat Data' as processing all the time

Dear Magento administrators/programmers, you may be stuck in a problem with index management of magento very often.
The problem synopsis is the 'Category Flat Data' index shows "Processing" all the time even after re-indexing many times.


There are many causes for this issue.
One simple solution is to truncate table `catalog_category_flat_store_1`.

If it wasn't work then enable "log" from magento's backend configuration. Check debug message in /var/log/exception.log file. If it says anything relevant to permission to database user then from your cPanel or web host manager grant the appropriate permissions to the database user. This is all you needed to do and hoorray, you got the rid of the messages "Some problem with reindexing process".

Another thing that might be the table being locked. To get rid of it empty the /var/locks folder.

Magento admin 404 error


Generally this error is being shown up after site migration.

Fire below query against your magento database to overcome 404 error on magento admin page.
Take backup of your store's database before running query.

SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

How to reset Magento Admin Password


To change your Magento admin password, go to your cPanel > phpMyAdmin, select your Magento database, click the SQL tab and paste this query:

UPDATE admin_user SET password=CONCAT(MD5('sGnewpass'), ':sG') WHERE username='AdminUsername';


Note: You have to change newpass in the MD5('sGnewpass') with your new password, and change *AdminUsername* to your Magento admin username.

Execute the query by clicking the Go buttong and your password will be changed.

Magento - Add breadcrumbs in pages where magento do not provide them

Add in the bottom of your breadcrumbs.phtml file

<?php if(!$crumbs): ?>
<?php 
$urlRequest = Mage::app()->getFrontController()->getRequest();

$urlPart =  $urlRequest->getOriginalPathInfo();
if(is_null($urlPart))
{
    $urlPart = $urlRequest->getPathInfo();
}

$urlPart = substr($urlPart, 1 );
$currentUrl = $this->getUrl($urlPart);
 
$controllerName = str_replace("/", " ", $urlPart);
$controllerName = str_replace("_", " ", $controllerName);
$controllerName = str_replace("-", " ", $controllerName);
$controllerName = ucfirst($controllerName);

// Put title if nothing found in url (i.e Home page)
$title_prefix = Mage::getStoreConfig('design/head/title_prefix');
if(empty($controllerName)) {
    $controllerName = str_replace($title_prefix,'', $this->getLayout()->getBlock('head')->getTitle());
}

?>
<div class="breadcrumbs">
<ul>
    <li class="home">
        <a title="<?php echo $this->__('Go to Home Page') ?>" href="<?php echo $this->getUrl() ?>"><?php echo $this->__('Home') ?></a>
    </li>
    <li> / </li>
    <li>
        <strong><?php echo $this->__($controllerName) ?></strong>
    </li>
</ul>
</div>
<?php endif; ?>

Category list in magento

    <?php foreach ($this->getStoreCategories() as $_category): ?>
        <?php echo $this->drawItem($_category) ?>
    <?php endforeach ?>

Magento -- host on Godaddy - No input file specified

In Magento folder, there should be a .htaccess file. Open that file up and add the following line:
AddHandler x-httpd-php5 .php
Now when you go to the Magento index page, you should see a ‘No Input File Specified’ error. This is another easy fix.
If you do not already have a php.ini file in your main folder, you need to create one. This will only work if you have selected the option of using Hosting Connection 2.0 . This will allow you to modify server settings for your site.
Rename 'php.ini' to 'php5.ini' for it to recognize.Then add following line:
cgi.fix_pathinfo = 1


php5.ini
register_globals = on
allow_url_fopen = on
cgi.fix_pathinfo = 1