Wednesday, December 19, 2012
Order Edit or Update From Front End in Magneto
Hi,
I done with module called order update where you can edit a pending order from front-end in your account section
it will work same as like order edit in admin
any help needed contact me
Tuesday, December 18, 2012
Store Credit Or Customer Balance Module in Magneto
Hi,
I Done with Store Credit module any help need please contact me i can help you out
in this once order is invoiced and made credit memo at that time customer can re use that balance to buy other product
I Done with Store Credit module any help need please contact me i can help you out
in this once order is invoiced and made credit memo at that time customer can re use that balance to buy other product
Tuesday, October 16, 2012
Get Magento Version in Magento Programmatically
If you need to get your Magento project version Programmatically use below code
$m= new Mage;
$version=$m->getVersion();
echo $version;
Wednesday, August 29, 2012
Buy X Product get least price product Free in magneto
Hi,
We can write a module which will give option in Shopping Cart Price Rules where if customer buys X product and he will get very least or minimum price product as free
i explained clear in my Magento post please go to below link
http://www.magentocommerce.com/boards/member/356269/
Importing and exporting category in magento Programmatically
Hi,
To import and export please see this below link which will clearly explain how to do
http://www.magentocommerce.com/boards/member/356269/
To import and export please see this below link which will clearly explain how to do
http://www.magentocommerce.com/boards/member/356269/
Tuesday, August 28, 2012
Display Current category ‘s Parent subcategory in magento programmatically
Please check this link it will explain clearly how to display current category's parent subcategory's in magneto
http://www.magentocommerce.com/boards/member/356269/
http://www.magentocommerce.com/boards/member/356269/
Sunday, July 29, 2012
Adding Custom Add to cart button in Magento
Hi,
we can create custom add to cart link or button from product id you can use below code
<button onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')" class="button btn-cart" title="Add to Cart" type="button"><span><span>Add to Cart</span></span></button>
Tuesday, June 26, 2012
Happy Hours Module OR Hourly base promostion in Magento
Hi,
Happy Hours module
in this module
- we can select days and between time only in that time and days discount can apply
- Select discount %
- Apply completed catalog products
- It can apply for special price or original price which you can set from back end
More detail contact me
Thursday, June 7, 2012
Displaying Subcategory or Top Level Subcategory in Left Nevegation in magento
Hi,
Some time we need to display all Subcategory of the current category that is the level2 of current category’s subcategory
so to solve this issue just set your current category id or just get current category id and set to $currentCategoryID variable
i keep this file in root and run in browser
you can make it use of this code and call in left navigation in list page
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/../app/Mage.php';
Mage::app();
$currentCategoryID=99;
function getParentTopCategory($category)
{
if($category->getLevel() == 2){
return $category;
} else {
$parentCategory = Mage::getModel('catalog/category')->load($category->getParentId());
return getParentTopCategory($parentCategory);
}
}
function Subcategory($subcats){
echo '<ul>'; foreach($subcats as $_category)
{
// $_category = Mage::getModel('catalog/category')->load($subCatId);
if($_category->getIsActive())
{
$caturl = $_category->getURL();
$catname = $_category->getName();
echo '<li>';
echo '<a href="'.$caturl.'" title="'.$catname.'">'.$catname.'</a>';
echo '</li>';
$subcats3 = $_category->getChildrenCategories();
if ($subcats3) {
Subcategory($subcats3);
}
}
}
echo '</ul>';
}
// $openCatId = getParentTopCategory(Mage::getModel('catalog/category')->load($currentCategoryID))->getId();
//OR you can use below code to get parent catgeory id of lavel 2
$path=explode('/',Mage::getModel('catalog/category')->load($currentCategoryID)->getPath());
$openCatId= $path[2];
$cat = Mage::getModel('catalog/category')->load($openCatId);
$subcats = $cat->getChildrenCategories();
if ($subcats) {
foreach($subcats as $_category)
{
if($_category->getIsActive())
{
$caturl = $_category->getURL();
$catname = $_category->getName();
echo '<a href="'.$caturl.'" title="'.$catname.'">'.$catname.'</a><br>';
$subcats2 = $_category->getChildrenCategories();
// exit;
if ($subcats2) {
Subcategory($subcats2);
}
}
}
}
?>
http://www.magentocommerce.com/boards/viewthread/283368/
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);
Sunday, February 5, 2012
Reinstall or Re- install custom module in Magento
We can re-install the custom module in Magento
Delete the appropriate entry in the core_resource db table and delete the database table of your module.
Delete the appropriate entry in the core_resource db table and delete the database table of your module.
Friday, January 27, 2012
Getting a Price Filter of category or Category Filters in magento programmatically
Hi,
If you need to call or display category filters by using category id in magneto use this code
this below code will display price Filter of category
If you need to call or display category filters by using category id in magneto use this code
this below code will display price Filter of category
$html='<div>';
$html .= '
<h4>Price</h4>
<ul class="price_grid">';
$html .= $this->priceHtmlnav($maincategoryId);
$html .='</ul>';
echo $html;
/*price block html
it took price filter and display in menu*/
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);
}
$attributes = $layer->getFilterableAttributes('price');
foreach ($attributes as $attribute) {
if ($attribute->getAttributeCode() == 'price') {
$filterBlockName = 'catalog/layer_filter_price';
$result = $this->getLayout()->createBlock($filterBlockName)->setLayer($layer)->setAttributeModel($attribute)->init();
foreach($result->getItems() as $option) {
$t=str_replace('<span class="price">', "", $option->getLabel());
$t=str_replace('</span>', "", $t);
$html .='<li><a href="'.$category->getUrl().'?price='.$option->getValue()
.'">'.$t.'</a></li>';
}
}
}
return $html;
}
Tuesday, January 17, 2012
Creating Renderer file for admin Grid in magnento programmatically
Hi,
to use renderer file or concept for admin grid check this link which make your life simpler
http://www.magentocommerce.com/boards/viewthread/271027/
to use renderer file or concept for admin grid check this link which make your life simpler
http://www.magentocommerce.com/boards/viewthread/271027/
Wednesday, January 11, 2012
Product Image Re-size with out frame or removing white space
Hi,
Need to remove the white border around your images?
when we re-size product image we will get white space in border, so we can remove that white space when product image is re-sized
use this code to re-size the product image with out white space
->constrainOnly(true) This will not resize an image that is smaller than the dimensions inside the resize() part.
->keepAspectRatio(true) This will not distort the height/width of the image.
->keepFrame(false) This will not put a white frame around your image.
This would resize your images to a max 350 width and constrain the height. If your image is taller than it is wide, you will end up with a nicely resized vertical image.
Need to remove the white border around your images?
when we re-size product image we will get white space in border, so we can remove that white space when product image is re-sized
use this code to re-size the product image with out white space
<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(135)->keepFrame(FALSE); ?>
->constrainOnly(true) This will not resize an image that is smaller than the dimensions inside the resize() part.
->keepAspectRatio(true) This will not distort the height/width of the image.
->keepFrame(false) This will not put a white frame around your image.
<?php echo $this->helper('catalog/image')->init($_product, 'image')->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->resize(350, null) ?>
This would resize your images to a max 350 width and constrain the height. If your image is taller than it is wide, you will end up with a nicely resized vertical image.
Category Image Re-size
Hi,
We don't have any function to re-size the category image, i saw one post where it clearly mention how to do it
call this code where you need to display
and extend category model to your local system or your custom module
XML
in side model folder add this file Category.php and paste this code
We don't have any function to re-size the category image, i saw one post where it clearly mention how to do it
call this code where you need to display
$_category=Mage::getModel('catalog/category')->load($categoryId());
$_imgUrl = $_category->getResizedImage(70,70);
and extend category model to your local system or your custom module
XML
<global>
<models>
<catalog>
<rewrite>
<category>NameSpace_Modulename_Model_Category</category>
</rewrite>
</catalog>
</models>
</global>
in side model folder add this file Category.php and paste this code
<?php
class NameSpace_Modulename_Model_Category extends Mage_Catalog_Model_Category
{
public function getResizedImage($width, $height = null, $quality = 100) {
if (! $this->getImage ())
return false;
$imageUrl = Mage::getBaseDir ( 'media' ) . DS . "catalog" . DS . "category" . DS . $this->getImage ();
if (! is_file ( $imageUrl ))
return false;
$imageResized = Mage::getBaseDir ( 'media' ) . DS . "catalog" . DS . "product" . DS . "cache" . DS . "cat_resized" . DS . $this->getImage ();// Because clean Image cache function works in this folder only
if (! file_exists ( $imageResized ) && file_exists ( $imageUrl ) || file_exists($imageUrl) && filemtime($imageUrl) > filemtime($imageResized)) :
$imageObj = new Varien_Image ( $imageUrl );
$imageObj->constrainOnly ( true );
$imageObj->keepAspectRatio ( true );
$imageObj->keepFrame ( false );
$imageObj->quality ( $quality );
$imageObj->resize ( $width, $height );
$imageObj->save ( $imageResized );
endif;
if(file_exists($imageResized)){
return Mage::getBaseUrl ( 'media' ) ."/catalog/product/cache/cat_resized/" . $this->getImage ();
}else{
return $this->getImageUrl();
}
}
}
Display category images in top menu or multi- column top menu with images in magento
Hi,
I used Raptor Explodedmenu extension for multi- column top menu
but i need to display images of subcategory of particular category ex;- Brand etc so i customized the Raptor Explodedmenu extension and attached in this post
in admin side you have to mention name of the parent category which sub-category images has to display not name
check this link
http://www.magentocommerce.com/boards/viewthread/270613/
I used Raptor Explodedmenu extension for multi- column top menu
but i need to display images of subcategory of particular category ex;- Brand etc so i customized the Raptor Explodedmenu extension and attached in this post
in admin side you have to mention name of the parent category which sub-category images has to display not name
check this link
http://www.magentocommerce.com/boards/viewthread/270613/
Thursday, January 5, 2012
Apply coupon discount on Original Price not on special price in magento programmatically
Hi,
In Magento Default coupon code will apply to special price if special price is there else it will apply to original price ,
but in some case we need to apply coupon code discount to original price and then apply to special price
EX:- Special price 1000
Original Price :- 2000
Coupon discount is 10%
Then in cart page it will show special price- discountamount( acc to special price) i't 1000-100 = 900
but we need special price- discountamount( acc to Original price) i'e 1000- 200 =800
for that we need to create a event
add this xml code in config.xml in side events tag i'e <events></events>
And created Observer.php inside your module/model if not exists else add only this function newcoupondiscountcal($observer) in side Observer class
clear cache and apply the code
In Magento Default coupon code will apply to special price if special price is there else it will apply to original price ,
but in some case we need to apply coupon code discount to original price and then apply to special price
EX:- Special price 1000
Original Price :- 2000
Coupon discount is 10%
Then in cart page it will show special price- discountamount( acc to special price) i't 1000-100 = 900
but we need special price- discountamount( acc to Original price) i'e 1000- 200 =800
for that we need to create a event
add this xml code in config.xml in side events tag i'e <events></events>
<!-- event for default coupon but discount will apply for MRP-->
<salesrule_validator_process>
<observers>
<new_dicount_coupon>
<type>singleton</type>
<class>Namespcae_Modulename_Model_Observer</class>
<method>newcoupondiscountcal</method>
</new_dicount_coupon>
</observers>
</salesrule_validator_process>
And created Observer.php inside your module/model if not exists else add only this function newcoupondiscountcal($observer) in side Observer class
class Namespcae_Modulename_Model_Observer
{
//event for default coupon but discount will apply for MRP
public function newcoupondiscountcal($observer)
{
$item=$observer['item'];
$rule=$observer['rule'];
$rulePercent = max(0, 100-$rule->getDiscountAmount());
//print_r($rule->getData()); exit;
if($rule->getSimpleAction()=='by_percent') {
$disPer=$rule->getDiscountAmount();
$product=Mage::getModel('catalog/product')->load($item->getProductId());
$ratdisc=($product->getPrice()*$disPer)/100;
$DiscountAmount=$ratdisc+$item->getDiscountAmount();
$BaseDiscountAmount=$ratdisc+$item->setBaseDiscountAmount();
$result = $observer['result'];
$result->setDiscountAmount($DiscountAmount);
$result->setBaseDiscountAmount($BaseDiscountAmount);
}
}
clear cache and apply the code
Wednesday, January 4, 2012
Creating Custom Web Service Api In magento programmatically
Hi,
Please check this post which will give complete structure for creating custom api and call
http://www.magentocommerce.com/boards/viewthread/270076/
Please check this post which will give complete structure for creating custom api and call
http://www.magentocommerce.com/boards/viewthread/270076/
Tuesday, January 3, 2012
Creating or Calling deafult Soap or Webservice API in magento programmatically
Hi,
As you all know in magneto we can create web services by using soap in magento
Magento as set of default API, i am using one default api writing code please check it
First Create web service user and role in magneto back end (system->Web Service) and assign roles to user
Enable soap dll i'e extension=php_soap.dll from your php.ini file
Paste this code in file and place this file in root folder or as you wish and run this file through browser
As you all know in magneto we can create web services by using soap in magento
Magento as set of default API, i am using one default api writing code please check it
First Create web service user and role in magneto back end (system->Web Service) and assign roles to user
Enable soap dll i'e extension=php_soap.dll from your php.ini file
Paste this code in file and place this file in root folder or as you wish and run this file through browser
<?php
$proxy = new SoapClient('http://yourdomine/index.php/api/soap/?wsdl');
$sessionId = $proxy->login('USERNAME', 'API_Key'); // you will get this when you create web service user in admin side
$filters = array(
'sku' => array('like'=>'test%')
);
$products = $proxy->call($sessionId, 'product.list', array($filters));
var_dump($products);
?>
Subscribe to:
Posts (Atom)