Tuesday, May 29, 2012
Disabling Google Tracking from a particular system or browser in Google analytic
Hi,
We can disable or switch of Google tracking from Google analytic of a particular system or browser
just download this file and then edit your Google analytic account and save it
place this file in root folder and then run this .html file in browser
so this will make Google analytic not track you click in your account so you will get clicks or tracking from other system
Note:- Please run in your system in every browser and also run when you clear your cache so it will set your browser not track in Google
Just Download the file from this link
http://www.magentocommerce.com/boards/viewthread/282323/
Friday, May 18, 2012
Calling block programmatically in magento
Module page
Calling Static Block
OR
{{block type='core/template' template='callouts/topslider.phtml' }}
<?php echo $this->getLayout()->createBlock('newmodule/newblock')->setTemplate('newmodule/newblock.phtml')->toHtml(); ?>
Calling Static Block
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('indentifer')->toHtml() ?>
OR
$block = Mage::getModel('cms/block')->load('identifier');
echo $block->getTitle();
echo $block->getContent();
In CMS PAge
{{block type='core/template' template='callouts/topslider.phtml' }}
Tuesday, April 3, 2012
Error! Secure Hash validation failed issue in Secure Ebs in Magento
Hi,
In Secure Ebs we will get a error called Error! SecureHash validation failed to solve this issue use below code
open app\code\core\Mage\Secureebs\Block\Standard\Redirect.php
before this line
Paste this code
Enjoy
In Secure Ebs we will get a error called Error! SecureHash validation failed to solve this issue use below code
open app\code\core\Mage\Secureebs\Block\Standard\Redirect.php
before this line
$form->addField('reference_no', 'hidden', array('name'=>'reference_no', 'value'=>$referenceno));Paste this code
$secretKey = Mage::getSingleton('secureebs/config')->getSecretKey(); // Our SecretKey
$account_id = Mage::getSingleton('secureebs/config')->getAccountId(); //account ID
$string = "$secretKey|$account_id|$amount|$referenceno|$returnurl|$mode";
$secure_hash = md5($string);
$form->addField('secure_hash','hidden', array('name'=>'secure_hash', 'value'=>$secure_hash));Enjoy
Tuesday, February 21, 2012
Adding New option in catgeory sort by OR Adding Most viewed or most popluar option for sort by in category list page in Magento
Hi,
If you need to added new sort by option like most viewed etc.. follow the steps
override app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php
in local folder and add or override only this 2 functions
Replace default Toolbar.php code by this code (be care full on class name it depends on your module name )
I took ex;- Most Viewed
You can also check all attached file in
http://www.magentocommerce.com/boards/viewthread/273724/
If you need to added new sort by option like most viewed etc.. follow the steps
override app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php
in local folder and add or override only this 2 functions
Replace default Toolbar.php code by this code (be care full on class name it depends on your module name )
I took ex;- Most Viewed
<?php
/**
pradeep.kumarrcs67@gmail.com
*/
class Custommodule_Catalog_Block_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
{
/**
* Retrieve available Order fields list
*
* @return array
*/
public function getAvailableOrders()
{
$this->addOrderToAvailableOrders('mostviewd', 'Most Popular');
//echo $this->getCurrentOrder(); exit;
$this->removeOrderFromAvailableOrders('position');
$this->removeOrderFromAvailableOrders('relevance');
$this->setDefaultOrder('mostviewd');
$this->setDefaultDirection('asc');
$this->removeOrderFromAvailableOrders('entity_id');
krsort($this->_availableOrder);
return $this->_availableOrder;
}
public function setCollection($collection)
{
$this->_collection = $collection;
$this->_collection->setCurPage($this->getCurrentPage());
// we need to set pagination only if passed value integer and more that 0
$limit = (int)$this->getLimit();
if ($limit) {
$this->_collection->setPageSize($limit);
}
if ($this->getCurrentOrder()) {
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}
if($this->getCurrentOrder()=='mostviewd') {
$this->_collection->getSelect()->
joinInner('report_event AS _table_views',
' _table_views.object_id = e.entity_id',
'COUNT(_table_views.event_id) AS views')->
group('e.entity_id')->order('views DESC');
}
$sql = $this->_collection->getSelectSql(true);
$this->_collection->getSelect()->reset()->from(
array('e' =>new Zend_Db_Expr("({$sql})")),
array('e' => "*")
);
$limit= $this->getDefaultPerPageValue();
$page = $this->getRequest()->getParam('p');
if(isset($page))
if(($page - 1) == 0)
$this->_collection->getSelect()->limit($limit);
else
$this->_collection->getSelect()->limit($limit, ($page - 1) * $limit);
else
$this->_collection->getSelect()->limit($limit);
$this->_collection->load();
// $this->_collection->printlogquery(true); exit;
return $this;
}
}You can also check all attached file in
http://www.magentocommerce.com/boards/viewthread/273724/
Thursday, February 9, 2012
Displaying Price filter of catgeory or layer filter in magento programmatically
Hi,
If you need to display layer price filter, we can display in 2 type
one is calling default block but issue is some time price will not display if you click price filter or if cache is disabled
Default Price filter
and call this funtion
To over the default issue i write custom code so even if cache is disabled the link will display
You can check same post in my magento forum with file attached
http://www.magentocommerce.com/boards/viewthread/272901/
If you need to display layer price filter, we can display in 2 type
one is calling default block but issue is some time price will not display if you click price filter or if cache is disabled
Default Price filter
public function priceHtmlnav($maincategoryId) {
$html ='';
$layer = Mage::getModel('catalog/layer');
$category = Mage::getModel('catalog/category')->load($maincategoryId);
if ($category->getId()) {
$origCategory = $layer->getCurrentCategory();
$layer->setCurrentCategory($category);
}
$r=Mage::getModel('catalog/layer_filter_price')
->setLayer($layer);
$range = $r->getPriceRange();
$dbRanges = $r->getRangeItemCounts($range);
$data = array();
foreach ($dbRanges as $index=>$count) {
$data[] = array(
'label' => $this->_renderItemLabel($range, $index),
'value' => $index . ',' . $range,
'count' => $count,
);
}
foreach($data as $d){
$t=str_replace('<span class="price">', "", $d['label']);
$t=str_replace('</span>', "", $t);
$html .= '<li><a href="'.$category->getUrl().'?price='.$d['value']
.'">'.$t.'</a></li>';
}
return $html;
} and call this funtion
$html=''
$html .= '
<h4>Price</h4>
<ul class="price_grid">';
$html .= $this->priceHtmlnav($maincategoryId);
$html .='</ul>';
echo $html; To over the default issue i write custom code so even if cache is disabled the link will display
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
Mage::app();
$storename='default';
function _renderItemLabel($range, $value)
{
$store = Mage::app()->getStore();
$fromPrice = $store->formatPrice(($value-1)*$range);
$toPrice = $store->formatPrice($value*$range);
return Mage::helper('catalog')->__('%s - %s', $fromPrice, $toPrice);
}
$html = '<h4>Price</h4>
<ul class="price_grid">';
$layer = Mage::getModel('catalog/layer');
$category = Mage::getModel('catalog/category')->load(6);
if ($category->getId()) {
$origCategory = $layer->getCurrentCategory();
$layer->setCurrentCategory($category);
}
$r=Mage::getModel('catalog/layer_filter_price')
->setLayer($layer);
$range = $r->getPriceRange();
$dbRanges = $r->getRangeItemCounts($range);
$data = array();
foreach ($dbRanges as $index=>$count) {
$data[] = array(
'label' => _renderItemLabel($range, $index),
'value' => $index . ',' . $range,
'count' => $count,
);
}
foreach($data as $d){
$html .= '<li><a href="'.$category->getUrl().'?price='.$d['value']
.'">'.$d['label'].'</a></li>';
}
$html .='</ul>';
echo $html;
?>
You can check same post in my magento forum with file attached
http://www.magentocommerce.com/boards/viewthread/272901/
Monday, February 6, 2012
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '4-0-1' for key 'PRIMARY', SQL error when updating products in Magento
Hi
When you edit products from back end
i\’e when updating products in admin you will get one sql error Integrity constraint violation: 1062 Duplicate or SQLSTATE[23000]
this error will happen if you install the module called simple organic for config products
so there is quick fix for this issue
Class: OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price
Method: public function catalogProductSave(Mage_Index_Model_Event $event)
file path is
app\code\community\OrganicInternet\SimpleConfigurableProducts\Catalog\Model\Resource\Eav\Mysql4\Product\Indexer\Price.php
Change:
on line 58 to:
Enjoy
When you edit products from back end
i\’e when updating products in admin you will get one sql error Integrity constraint violation: 1062 Duplicate or SQLSTATE[23000]
this error will happen if you install the module called simple organic for config products
so there is quick fix for this issue
Class: OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price
Method: public function catalogProductSave(Mage_Index_Model_Event $event)
file path is
app\code\community\OrganicInternet\SimpleConfigurableProducts\Catalog\Model\Resource\Eav\Mysql4\Product\Indexer\Price.php
Change:
$this->cloneIndexTable(true);on line 58 to:
$this->clearTemporaryIndexTable();Enjoy
Getting Associated products of bundle products or displaying simple products of bundle products
If you need to get Associated products sku of bundle products use below code
$product_id=7763;
$bundled_product = new Mage_Catalog_Model_Product();
$bundled_product->load($product_id);
$selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection(
$bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product
);
$bundled_items = array();
foreach($selectionCollection as $option)
{
$bundled_items[] = Mage::getModel('catalog/product')->load($option->product_id)->getSku();
}
print_r($bundled_items);
Subscribe to:
Posts (Atom)