Clear log table & speedup the website speed as well as free up the server space

Magento keep the log file internally to track the visitor, cart, customer, report etc. Once the website get older the logs get larger and that make slow down the website speed and consume the server space

In this article i will guide you how to prevent large log data. That will be beneficial for your website speed and server space

There is two way to achieve the target:
1) Manual process: Go to the database and truncate the below tables time to time:
dataflow_batch_export
dataflow_batch_import
log_customer
log_quote
log_summary
log_summary_type
log_url
log_url_info
log_visitor
log_visitor_info
log_visitor_online
report_viewed_product_index
report_compared_product_index
report_event

2) Clear the log table using cronjobs: This process is safe and easy to implement. Create a php script, using mysql query truncate data from database table.add This php script at cronjob as per as your requirement.
getConnection(‘core_write’);
$query1 = “truncate table dataflow_batch_export”;
$query2 = “truncate table dataflow_batch_import”;
$query3 = “truncate table log_customer”;
$query = “truncate table log_quote”;
$query4 = “truncate table log_summary”;
$query5 = “truncate table log_summary_type”;
$query6 = “truncate table log_url”;
$query7 = “truncate table log_url_info”;
$query8 = “truncate table log_visitor”;
$query9 = “truncate table log_visitor_info”;
$query10 = “truncate table log_visitor_online”;
$query11 = “truncate table report_viewed_product_index”;
$query12 = “truncate table report_compared_product_index”;
$query13 = “truncate table report_event”;

$writeConnection->query($query1);
$writeConnection->query($query2);
$writeConnection->query($query3);
$writeConnection->query($query4);
$writeConnection->query($query5);
$writeConnection->query($query6);
$writeConnection->query($query7);
$writeConnection->query($query8);
$writeConnection->query($query9);
$writeConnection->query($query10);
$writeConnection->query($query11);
$writeConnection->query($query12);
$writeConnection->query($query13);
$writeConnection->query($query13);
?>
Add the php script in cronjob after 15-30 days. so the log file will clear time to time and website speed didn’t get slow down, also it save your server space.

Reindex magento data via SSH

The fastest way to re-index magento data is manually via SSH.
When you re-index from admin section, sometime the re-indexing process get stuck due to expire session or crss maximum execution time or any other reason. The best and fastest way to re-indexing the Magento data is via SSH

In this article i will guide you how to re-index via SSH:

  • Login to your SSH account. if you didn’t have please contact with the server guy, they will provide you.
  • Go to the server directory where magento get installed
  • Got to the “shell” directory. cd your_magento_directory/shell
  • now you can use below code to re-index magento data:
    php -f indexer.php — -reindex catalog_product_attribute
    php -f indexer.php — -reindex catalog_product_price
    php -f indexer.php — -reindex catalog_url
    php -f indexer.php — -reindex catalog_product_flat
    php -f indexer.php — -reindex catalog_category_flat
    php -f indexer.php — -reindex catalog_category_product
    php -f indexer.php — -reindex catalogsearch_fulltext
    php -f indexer.php — -reindex cataloginventory_stock
  • if you want to re-index all then use:
    php -f indexer.php reindexall

Session Management In magento1

In this blog i will explain you how to set, retrieve and unset session variable in Magento.
Before start i would like to inform you, By default Magento equipped with three type of session:

  • Core Session
  • Customer Session
  • Checkout Session

Core Session

Core sessions are bone of Magento, you can use it anywhere any place in the code.
Set core session: Mage::getSingelton(‘core/session’)->set();
This will set the value (value_of_session) in session variable name (your_session_name).
EX:
$myValue =’test’;
Mage::getSingleton(‘core/session’)->setMyValue($myValue);
In the above example i have set the value “test” in variable myValue, and set myValue in session. Now the session “MyValue” set with value “test”.
Retrieve core session value: Mage::getSingelton(‘core/session’)->get();,
This will return the session variable value which you set in “your_session_name”.
Unset core session:Mage::getSingleton(‘core/session’)->uns();, This will delete session value which you set in ““.

Same with the customer and checkout session:
Mage::getSingleton(‘customer/session’)
Mage::getSingleton(‘checkout/session’)

Magento : Get Base Url , Skin Url , Media Url , Js Url , Store Url and Current Url

Get Url in phtml files

  • Get Base Url : Mage::getBaseUrl();
  • Get Skin Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
  • Unsecure Skin Url : $this->getSkinUrl(‘images/imagename.jpg’);
  • Secure Skin Url : $this->getSkinUrl(‘images/imagename.gif’, array(‘_secure’=>true));
  • Get Media Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
  • Get Js Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
  • Get Store Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
  • Get Current Url Mage::helper(‘core/url’)->getCurrentUrl();

Get Url in cms pages or static blocks

  • Get Base Url : {{store url=””}}
  • Get Skin Url : {{skin url=’images/imagename.jpg’}}
  • Get Media Url : {{media url=’/imagename.jpg’}}
  • Get Store Url : {{store url=’mypage.html’}}

Carshoez

Tire & Wheel sale website. CarShoez makes it easy to buy tires online. One thing we know about consumers is that they want free shipping, so we offer just that on all orders! We also know that consumers want the best deals on tires they can find, which is why CarShoez is your best choice for discount tires. Our goal is to provide you with the cheapest tires online. We don’t sell just cheap tires, but high quality, cheap tires for cars, trucks and more! Though our prices are low, you won’t have to worry about quality because we carry tires from only the leading brands in the industry including Michelin® Tires, BFGoodrich Tires, Uniroyal® Tires, Pirelli Tires, Yokohama Tires and Toyo Tires. View our online tire catalogs to find your tire choice! You can also check out what out what sales and deals we currently have going on! As you browse our online store, if you don’t find what you need, please send us an email or visit us in Fort Lauderdale, FL and we will get you the products you need. you can check it from Carshoez

Developer Name

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Developer Name” background_layout=”light” text_orientation=”left” text_font_size=”14″ use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

t-s-1

I love to Develop

I love to introduce myself as a hardcore Web Developer.

Developer Name

Development Manager

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Design Manager

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” text_font_size=”14″ use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

t-s-1

Its Awesome Work

I love to introduce myself as a hardcore Web Designer.

Designer Name

Design Manager

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

CEO NAME

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” text_font_size=”14″ use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

t-s-1

Hello World

I love to introduce myself as a hardcore Web Designer.

CEO NAME

founder & ceo

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]