Web Performance Optimization

Web performance Optimization

We optimize your website by analyzing the pattern of the website. By using improved methods of optimization we makes your web pages fly while rendering.

Some of the points from our checklist are:

  • By improving your code, optimizing JS for non-blocking while rendering.
  • Sharing the web page load(I/O) by using a CDN and Seprate Session and Caching servers.
  • By Using Caching technology like Varnish, aiCache.
  • Using shared network caching like Memcached, Redis.
  • Optimizing the structure of your website for faster rendering in browsers like IE.
  • Optimizing Database Servers like Mysql, PostgreSQL for dynamic websites.
  • Web Server Optimization for web servers like Nginx, Apache, IIS, Tomcat, IBM Http Server, JBOSS, Express.
  • Using right Headers for Cache Control.
  • Image Optimization and Compression.

 

Read More...

Magento

Get list of product attribute in Magento

# Get list of colors from Magento Installation

Let’s create a file called getcolors.php on Magento root folder.

require_once ( “app/Mage.php” );
umask(0);
Mage::app(“default”);
Mage::getSingleton(“core/session”, array(“name” => “frontend”));
$attribute = Mage::getSingleton(‘eav/config’)->getAttribute(‘catalog_product’, ‘color’);
if ($attribute->usesSource()) {
$options = $attribute->getSource()->getAllOptions(false);
}
print_r($options);

When you excute the file getcolors.php either from shell or browser, It will print the list of color used in product catalog.

Read More...

Magento

Add an External JS in Magento

To Add an External JS without any problem use this in XML Layout:

[box type=”info”]<reference name="head"><block type="core/text" name="google.cdn.jquery">
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript">jQuery.noConflict();</script>]]></text></action></block></reference>
]]>[/box]

The External JS will be added to the <head> tag.

Read More...

Magento

Zend_Db_Statement_Exception with message ‘SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry’

Exception ‘Zend_Db_Statement_Exception’ with message ‘SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry” while Catalog Url Indexing

Error:

Next exception ‘Zend_Db_Statement_Exception’ with message ‘SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘xxxx/xxx/xxx-‘ for key ‘UNQ_CORE_URL_REWRITE_REQUEST_PATH_STORE_ID” in /data/apache/beta/lib/Zend/Db/Statement/Pdo.php:234
Stack trace:

Soln:

– Find out the request path on Url Rewrites Data, there must be more than single entries for that request path.

– Out of the list  find out the entry whose request_path matches the target_path of any entry in the list.

– Open and Disable the Url Redirection( Set it to No).

– Reindex Catlog Url Indexes, Done.(php -f indexer.php — -reindex catalog_url)

Read More...

Magento

Magento Show Out of Stock Configurable Options – Magento 1.5+

To show Out of Stock options in configurable products, we need to make these changes:

Create a Local Module : Mindgeek_Outofstock
/app/code/local/Mindgeek/Outofstock/Product/Block/Product/View/Type/Configurable.php
/app/code/local/Mindgeek/Outofstock/etc/config.xml
/app/code/etc/modules/Mindgeek_Outofstock.xml

Rewrite /app/code/core/Mage/Catalog/Product/Block/Product/View/Type/Configurable.php

<config>
<modules>
<mindgeek_outofstock>
<version>0.1.0</version>
</mindgeek_outofstock>
</modules>
<global>
<blocks>
<catalog>
<rewrite>
<product_view_type_configurable>Mindgeek_Outofstock_Block_Product_View_Type_Configurable
</product_view_type_configurable>
</rewrite>
</catalog>
</blocks>
</global>
</config>

In /app/code/core/Mage/Catalog/Product/Block/Product/View/Type/Configurable.php

class Mindgeek_Outofstock_Block_Product_View_Type_Configurable  extends Mage_Catalog_Block_Product_View_Type_Configurable
{
//Rewrite getAllowProducts() function:
public function getAllowProducts()
{
if (!$this->hasAllowProducts()) {
$products = array();
$allProducts = $this->getProduct()->getTypeInstance(true)
->getUsedProducts(null, $this->getProduct());
foreach ($allProducts as $product) {
$products[] = $product;
}
$this->setAllowProducts($products);
}
return $this->getData(‘allow_products’);
}
}

Now changes required in design template, view.phtml

/app/design/frontend/purple/default/template/catalog/product/view.phtml

<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml(‘container2’, ”, true, true) ?>
<?php endif;?>

<?php if ($this->hasOptions()):?>
<?php echo $this->getChildChildHtml(‘container2’, ”, true, true) ?>
<?php endif;?>

Enable this Module from /app/etc/modules/Mindgeek_Outofstock.xml

<?xml version=”1.0″?>
<config>
<modules>
<Mindgeek_Outofstock>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Mindgeek_Outofstock>
</modules>
</config>

Done!!

Read More...

Magento

Magento URL Rewrites in a Collection

To Enable Url rewrites while using a Magento collection just add this to the end of collection:

->addUrlRewrite()

which adds URL rewrites to collection flag

Read More...

Magento

Magento redirect simple product to parent configurable product

Add this code in _initProduct() method in IndexController or ProductController in /app/code/core/Catalog/Product/controllers (Create same file in your local folder), which redirects the simple product to parent configurable product.

if($product->type_id==”simple”)
{
$configurable_product = Mage::getModel(‘catalog/product_type_configurable’);
$parentIdArray = $configurable_product->getParentIdsByChild($product->getId());

if(isset($parentIdArray[0]))
{
$product = Mage::getModel(‘catalog/product’)->load($parentIdArray[0]);
}
}

Note:

Read More...

Linux, Magento

Adding a Cron Job in Magento

Add the following lines to your module’s config.xml file under etc folder.

<crontab>

<jobs>

            <namespace_yourmodulename>

                <schedule><cron_expr>*/1 * * * *</cron_expr></schedule>

<run><model>navision/observer::methodToCall</model></run>

</namespace_yourmodulename>

</jobs>

</crontab>

 

Observer:

<?php

class Namespace_Yourmodulename_Model_Observer {

public static function methodToCall(){

//Code to Execute

Mage::log(“Cron Executed”);

}

}

?>

Note: Magento root file cron.php needs to be added to crontab on web server.

Read More...