HTML/JavaScript

Wednesday, October 23, 2013

Magento Remove Super Attribute from Configurable Product

Sometimes We need to remove the Attribute from already build Configurable product…As it is hard to remove but we can remove from MYSQL Raw Query …which against the Standard but if it is requried we can edit like this
To remove one super product attribute (as they are called) from all configurable products, you could execute this SQL query in the database:
DELETE FROM catalog_product_super_attribute WHERE attribute_id = “attribute ID which should be removed”
The table catalog_product_super_attribute links products to super product attributes. You can add and remove attributes to created configurable products there.

Magento adding Super Attribute to configurable products

Create attribute
  •     Drag it to appropriate attribute set
  •     Go to phpmyadmin, table ‘catalog_eav_attribute’ and look at the last one, note the ‘attribute id’, also note the product id -> go to catalog_product_entity and look for the configurable product you want, and note entity_id -> this is the product_id
  •     Go to catalog_product_super_attribute and insert new record with product_id and attribute_id, note of the product_super_attribute_id
  •     Go to catalog_product_super_attribute_label and insert new record with product_super_attribute_id and the value of your new attribute, like ‘Color’ or ‘Size’ which you used when adding the attribute in the admin
  •     Go back to admin and click the configurable product, you will notice none of your child products is associated to your configurable product.
  •     Click one of the child products, and select appropriate attribute value, you may also change the sku.
  •     Export all child products and add the new attribute and sku values to it, import it back and you are done or you may have to manually change all in the admin without using the dataflow.
Hope this will help you

Magento Log Cleaning

If certain precaution are not taken on time then magento Database could go extremely large.AS most of the low performance of the website is the Data which is not of used but stored in Database……Clearing these out not only saves disk space but can lead to some dramatic speed improvements as well.As Magento has several tables to store log details. These log tables has contain the customer Visited url, compared products, import & export Data flow table.
Magento has this features to clean these logs, but unfortunately this feature is disabled by default, most of the magento users to don’t turn it on.
There are two  ways to clear the log tables.
We can manually clear these log details by MYSQL Query
Enable Log cleaning from admin and set the cron job for that.
1. Manually Clean directly on Table:
i) Directly run this RAW query which will allow to delete the table
TRUNCATE dataflow_batch_export;
TRUNCATE dataflow_batch_import;
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
TRUNCATE log_visitor_online;
TRUNCATE report_viewed_product_index;
TRUNCATE report_compared_product_index;
TRUNCATE report_event;
TRUNCATE index_event;
Generally log table works in some of the follwoing functionality
catalog_product_view (products recently viewed box)
sendfriend_product
catalog_product_compare_add_product (recently compared products box and compare box)
checkout_cart_add_product
wishlist_add_product (wishlist box not wishlist itself)
wishlist_share .
2) Enable log cleaning in magento:
1. Go to System > Configuration > Advanced > System > Log Cleaning
by default Enable Log Cleaning is disbale make it enable and set the days so that when cron will run in that time it will delete all your log tables
and boom as excpected
Hope this will help you

Wednesday, October 9, 2013

How to show out of stock products to the end of the product list in Magento

First of all overwrite the file

app/code/core/Mage/Catalog/Model/Layer.php

and copy this file to

app/code/local/Mage/Catalog/Model/Layer.php

In function getProductCollection(), Put this code after line #102

<?php
$collection->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')->setOrder('inventory_in_stock', 'desc');
?>

How to get currency code in Magento

We know Magento support multiple currency. Use following code given below to check current currency in the Magento site frontend.

To get current currency code

<?php echo $current_currency_code = Mage::app()->getStore()
->getCurrentCurrencyCode(); ?>

If you looking for current currency symbol use :

<?php echo Mage::app()->getLocale()->currency(Mage::app()
->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>