Mage::getUrl('customer/account/login'); //login url Mage::getUrl('customer/account/logout'); //logout url Mage::getUrl('customer/account'); //My Account url Mage::getUrl('customer/account/create'); // Register url Mage::getUrl('checkout/cart'); //Checkout url
Saturday, August 27, 2011
How to get the customer login, logout, register and checkout url?
Friday, August 26, 2011
Magento Pagination Without Toolbar?
Add the below code to your end of "template/catalog/product/list.phtml" file.
<?php // manually get the toolbar block so we can do the page navigation $toolbar = $this->getToolbarBlock(); $toolbar->setCollection($_productCollection); if($toolbar->getCollection()->getSize() > 0): echo $toolbar->getPagerHtml(); //Pager echo $toolbar->__('Items %s to %s of %s total', $toolbar->getFirstNum(), $toolbar->getLastNum(), $toolbar->getTotalNum()); endif; ?>Thats it. It will work perfectly.
Tuesday, August 23, 2011
How to show total shopping cart price in Header Magento?
Edit the template\page\html\header.phtml file and add the below code to display total number of items and price in header.
<?php $count = $this->helper('checkout/cart')->getSummaryCount(); //get total items in cart $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price if($count==0) { echo $this->__('Items: %s',$count); } if($count==1) { echo $this->__(' Item: %s',$count); } if($count>1) { echo $this->__(' Items: %s',$count); } echo $this->__(' Total: %s', $this->helper('core')->formatPrice($total, false));
?>
How to move Cart from Right Sidebar to Header in Magento?
Find the below line in your page.xml file.
Add the below code inside to that block//Near line 70
Your new code will look like this
Finally Add the below code in your "\template\page\html\header.phtml" file.//new block top-container
//place this where ever you want the cart to show up. <?php echo $this->getChildHtml('topcart'); ?>Thats it. You can see the cart sidebar in your header section.
How to remove wishlist link url from top links in magento?
Comment the below line in your wishlist.xml file.
wishlist_link
How to add customer register link to the top links in magento?
Add the below line in your customer.xml file.
Register 11
Monday, August 22, 2011
Custom 'Sort by' drop-down menu options Lowest price, Higest price, Name A-Z, Name Z-A, Newest to Oldest & Oldest to Newest in magento
Edit "template/catalog/product/list/toolbar.phtml"
Original code:
Original code:
<div class="sort-by"> <label><?php echo $this->__('Sort By') ?></label> <select onchange="setLocation(this.value)"> <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?> <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>> <?php echo $this->__($_order) ?> </option> <?php endforeach; ?> </select> <?php if($this->getCurrentDirection() == 'desc'): ?> <a href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo $this->__('Set Ascending Direction') ?>"><img src="<?php echo $this->getSkinUrl('images/i_desc_arrow.gif') ?>" alt="<?php echo $this->__('Set Ascending Direction') ?>" class="v-middle" /></a> <?php else: ?> <a href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo $this->__('Set Descending Direction') ?>"><img src="<?php echo $this->getSkinUrl('images/i_asc_arrow.gif') ?>" alt="<?php echo $this->__('Set Descending Direction') ?>" class="v-middle" /></a> <?php endif; ?> </div>Replace with:
<fieldset class="sort-by"> <label><?php echo $this->__('Sort by') ?></label> <select onchange="setLocation(this.value)"> <option value="<?php echo $this->getOrderUrl('position', 'asc') ?>"<?php if($this->isOrderCurrent('position') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>> Featured </option> <option value="<?php echo $this->getOrderUrl('price', 'asc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>> Lowest Price </option> <option value="<?php echo $this->getOrderUrl('price', 'desc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> Highest Price </option> <option value="<?php echo $this->getOrderUrl('name', 'asc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>> Name A-Z </option> <option value="<?php echo $this->getOrderUrl('name', 'desc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> Name Z-A </option> <option value="<?php echo $this->getOrderUrl('entity_id', 'desc') ?>"<?php if($this->isOrderCurrent('entity_id') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> Newest to Oldest </option> <option value="<?php echo $this->getOrderUrl('entity_id', 'asc') ?>"<?php if($this->isOrderCurrent('entity_id') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>> Oldest to Newest </option> </select> </fieldset>
How to move magento search bar from header to sidebar?
Edit "app/design/frontend/<your theme>/<your theme>/layout/catalogsearch.xml"
Fine the line:
Fine the line:
Replace the reference name to left or right.
Friday, August 19, 2011
How to show all stores in magento top menu?
Edit "app/design/frontend/<your theme>/<your theme>/template/catalog/navigation/top.phtml" .
Add the below code before the line <?php echo $_menu ?>
Add the below code before the line <?php echo $_menu ?>
<li onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)" class="level0 first nav-store <?php if(strpos($_SERVER['REQUEST_URI'], '?___store') && !strpos($_SERVER['REQUEST_URI'], '?___store=default')): echo 'active'; else: echo ''; endif; ?>"> <a href="<?php echo $this->getUrl() ?>"><span><?php echo $this->__('SHOP BY BRAND') ?></span></a> <?php $store_groups = Mage::app()->getStores(); ?> <?php if(count($store_groups)>1): ?> <ul class="level0"> <?php $level_counter = 1;?> <?php foreach ($store_groups as $_eachStoreId => $val): ?> <li class="level1 nav-home-<?php echo $level_counter;?>"> <a href="<?php echo Mage::app()->getStore($_eachStoreId)->getHomeUrl() ?>"><span><?php echo Mage::app()->getStore($_eachStoreId)->getName(); ?></span></a> </li> <?php $level_counter++;?> <?php endforeach; ?> </ul> <?php endif; ?>
How to get all store details in magento?
<?php $allStores = Mage::app()->getStores(); foreach ($allStores as $_StoreId => $val) { $storeCode = Mage::app()->getStore($_StoreId)->getCode(); $storeName = Mage::app()->getStore($_StoreId)->getName(); $storeId = Mage::app()->getStore($_StoreId)->getId(); $storeUrl = Mage::app()->getStore($_StoreId)->getHomeUrl(); } ?>
How to add home page link in magento top menu?
Edit "app/design/frontend/<your theme>/<your theme>/template/catalog/navigation/top.phtml" .
Add the below line before the line <?php echo $_menu ?>
Add the below line before the line <?php echo $_menu ?>
<li class="home<?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()):?> active<?php endif;?>"><a href="<?php echo $this->getUrl('')?>"><?php echo $this->__('Home') ?></a></li>
Friday, August 12, 2011
How to change number of columns products fill in product list page?
Edit the below line in catalog/product/list.phtml
<?php $_columnCount = 4;//$this->getColumnCount(); ?>
Thursday, August 11, 2011
Bulk Emails import into Magento Newsletter Subscriber List
<?php require_once 'app/Mage.php'; umask( 0 ); Mage :: app( "default" ); //$_helper = new Mage_Newsletter_Model_Subscriber(); //$_helper->subscribe("myemail@e-mail.co.uk"); $emails = array("myemail4@e-mail.co.uk","myemail5@e-mail.co.uk","myemail6@e-mail.co.uk"); foreach($emails as $email){ $db = Mage::getSingleton('core/resource')->getConnection('core/write'); $query = "SELECT * FROM newsletter_subscriber WHERE subscriber_email = '$email'"; $result = $db->query($query); if($result->fetchAll()): echo "Email Not Added: $email<br/>"; else: $db->query("INSERT INTO newsletter_subscriber (`subscriber_id` , `store_id` , `change_status_at` , `customer_id` , `subscriber_email` , `subscriber_status` , `subscriber_confirm_code`) VALUES (NULL,'1',NULL,'0','$email','1',NULL)"); echo "Email Successfully Added: $email<br/>"; endif; } ?>
How to change the Magento Admin Panel Title?
Edit the main.xml file located at "/app/design/adminhtml/default/default/layout/main.xml"
On line 57 you will find:
On line 57 you will find:
Just edit the text within the title tags to whatever you want the new title to be.Magento Admin
How to Disable admin Latest Messages Notification in magento?
Just goto:
System > Configuration > Advanced > Disable Module Output and disable Mage_AdminNotification
System > Configuration > Advanced > Disable Module Output and disable Mage_AdminNotification
How to add Social Bookmarks link to Magento Product Page?
Add the below code into your view.phtml file located at "/app/design/frontend/base/default/your-template/catalog/product/view.phtml"
How to add Quantity Box in the Category Products Listing Page in magento?
Edit your list.phtml file located at "/app/design/frontend/default/your-theme/template/catalog/product/list.phtml".
Find the below code, line number at 61 for list mode and line number 103 for grid view:
Find the below code, line number at 61 for list mode and line number 103 for grid view:
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>replace it with,
<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>> <?php if(!$_product->isGrouped()): ?> <label for="qty"><?php echo $this->__('Qty') ?>:</label> <input type="text" name="qty" id="qty" maxlength="12" size = "3" value="<?php echo ($this->getMinimalQty($_product)?$this->getMinimalQty($_product):1) ?>" /> <?php endif; ?> </form>
Magento Search Showing All Products
If the search filter is not working as you need, then here is the solution :
-> Replace the catalogsearch folder under "app/design/frontend/default/your-theme/template" with "app/design/frontend/base/template/catalogsearch/".
-> Replace the catalogsearch.xml file under the "app/design/frontend/default/your-theme/layout/" with "app/design/frontend/base/layout/catalogsearch.xml".
-> Clear the cache.
-> Replace the catalogsearch folder under "app/design/frontend/default/your-theme/template" with "app/design/frontend/base/template/catalogsearch/".
-> Replace the catalogsearch.xml file under the "app/design/frontend/default/your-theme/layout/" with "app/design/frontend/base/layout/catalogsearch.xml".
-> Clear the cache.
CONNECT ERROR: Couldn't resolve host 'magento-community'
If you are trying to install any 3rd party extensions from your magento connect manager and getting such an error,
“CONNECT ERROR: Couldn't resolve host 'magento-community'”
Then the reason is the Magento Connect is not able to detect the download channel.
You will need to change the Magento Connect Version 1.0 to 2.0 when getting the extension key from magento extension page Or this can be installed using new connect manager by changing the extension key format.
For example: magento-community/Mage_myModule needs to be changed to http://connect20.magentocommerce.com/community/Mage_myModule
“CONNECT ERROR: Couldn't resolve host 'magento-community'”
Then the reason is the Magento Connect is not able to detect the download channel.
You will need to change the Magento Connect Version 1.0 to 2.0 when getting the extension key from magento extension page Or this can be installed using new connect manager by changing the extension key format.
For example: magento-community/Mage_myModule needs to be changed to http://connect20.magentocommerce.com/community/Mage_myModule
How to reindex manually using sql query?
Create a file called “reindex.php” inside your magento root folder and put the following code.
Then clear your cache.
<?php require_once 'app/Mage.php'; umask( 0 ); Mage :: app( "default" ); echo "Started Rebuilding Search Index At: " . date("d/m/y h:i:s"); //Locate the correct table. For example here im reindexing catalogsearch_fulltext table. $sql = "truncate catalogsearch_fulltext"; $mysqli = Mage::getSingleton('core/resource')->getConnection('core_write'); $mysqli->query($sql); /* Process_id Indexer_code 1 catalog_product_attribute 2 catalog_product_price 3 catalog_url 4 catalog_product_flat 5 catalog_category_flat 6 catalog_category_product 7 catalogsearch_fulltext 8 cataloginventory_stock 9 tag_summary */ $process = Mage::getModel('index/process')->load(7); $process->reindexAll(); echo "Finished Rebuilding Search Index At: " . date("d/m/y h:i:s"); ?>Then run this script by visiting www.yourdomain.com/reindex.php in your browser.
Then clear your cache.
Magento Product Thumbnail Image Switcher
This article which explains how to easily replace the default functionality of your product images (the pop-up window when you click on a thumbnail below the main image) with a image swapping functionality.
Step One
Edit the media.phtml file. It can be found at:app/design/frontend/base/default/template/catalog/product/view/media.phtml
Assuming that you have the default Magento file structure.
Step Two
Locate the code that we will be editing (on or around line 73 in media.phtml) and replace it with the replacement code below. Thats it!Original Code:
<a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>Replacement Code:
<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $_product->getName();?>" onclick="$('image').src = this.href; return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
Its tested with magento 1.5.1.0
Quick debug tips in magento
Mage::log() function is used to debug in magento. You can add items to magento’s system log and exception log in your code.
Here’s an example of it’s use:
1) Turn on your logging: Admin > Configuration > Developer > Log Settings > Enabled = Yes
2) Example code snippet where you might find this useful:
Here’s an example of it’s use:
1) Turn on your logging: Admin > Configuration > Developer > Log Settings > Enabled = Yes
2) Example code snippet where you might find this useful:
Mage::log(get_class_methods($this));3) Watch your var/log/system.log and var/log/exception.log for raw information from this.
Tuesday, August 9, 2011
How to get SQL Query as a string in magento?
If you are using collections, There are two ways of getting SQL from the collection of Magento.
1. Echoing Query String.
2. Getting the query String
1. Echoing Query String.
/** If $collection is your collection**/ $collection->printlogquery(true); /** Don't forget to write true in param**/But by this method you cannot assign the query you get echoed to some variable.
2. Getting the query String
$query=$collection->getSelectSql(true); echo $query;
Get ordered items and their details from ordered id in magento
$itemcount = 0; $order = Mage::getModel('sales/order')->load($order_id); $items = $order->getAllItems(); $itemcount=count($items); $name=array(); $unitPrice=array(); $sku=array(); $ids=array(); $qty=array(); if($itemcount > 0){ foreach ($items as $itemId => $item) { $name[] = $item->getName(); $unitPrice[]=$item->getPrice(); $sku[]=$item->getSku(); $ids[]=$item->getProductId(); $qty[]=$item->getQtyToInvoice(); } }
Delete test products, categories, customers, products reviews and ratings in magento
//Delete products
TRUNCATE TABLE `catalog_product_bundle_option`; TRUNCATE TABLE `catalog_product_bundle_option_value`; TRUNCATE TABLE `catalog_product_bundle_selection`; TRUNCATE TABLE `catalog_product_entity_datetime`; TRUNCATE TABLE `catalog_product_entity_decimal`; TRUNCATE TABLE `catalog_product_entity_gallery`; TRUNCATE TABLE `catalog_product_entity_int`; TRUNCATE TABLE `catalog_product_entity_media_gallery`; TRUNCATE TABLE `catalog_product_entity_media_gallery_value`; TRUNCATE TABLE `catalog_product_entity_text`; TRUNCATE TABLE `catalog_product_entity_tier_price`; TRUNCATE TABLE `catalog_product_entity_varchar`; TRUNCATE TABLE `catalog_product_link`; TRUNCATE TABLE `catalog_product_link_attribute`; TRUNCATE TABLE `catalog_product_link_attribute_decimal`; TRUNCATE TABLE `catalog_product_link_attribute_int`; TRUNCATE TABLE `catalog_product_link_attribute_varchar`; TRUNCATE TABLE `catalog_product_link_type`; TRUNCATE TABLE `catalog_product_option`; TRUNCATE TABLE `catalog_product_option_price`; TRUNCATE TABLE `catalog_product_option_title`; TRUNCATE TABLE `catalog_product_option_type_price`; TRUNCATE TABLE `catalog_product_option_type_title`; TRUNCATE TABLE `catalog_product_option_type_value`; TRUNCATE TABLE `catalog_product_super_attribute`; TRUNCATE TABLE `catalog_product_super_attribute_label`; TRUNCATE TABLE `catalog_product_super_attribute_pricing`; TRUNCATE TABLE `catalog_product_super_link`; TRUNCATE TABLE `catalog_product_enabled_index`; TRUNCATE TABLE `catalog_product_website`; TRUNCATE TABLE `catalog_product_entity`; TRUNCATE TABLE `cataloginventory_stock`; TRUNCATE TABLE `cataloginventory_stock_item`; TRUNCATE TABLE `cataloginventory_stock_status`; insert into `catalog_product_link_type`(`link_type_id`,`code`) values (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell'); insert into `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) values (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal'); insert into `cataloginventory_stock`(`stock_id`,`stock_name`) values (1,'Default');//Delete categories
TRUNCATE TABLE `catalog_category_entity`; TRUNCATE TABLE `catalog_category_entity_datetime`; TRUNCATE TABLE `catalog_category_entity_decimal`; TRUNCATE TABLE `catalog_category_entity_int`; TRUNCATE TABLE `catalog_category_entity_text`; TRUNCATE TABLE `catalog_category_entity_varchar`; TRUNCATE TABLE `catalog_category_product`; TRUNCATE TABLE `catalog_category_product_index`; insert into `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`position`,`level`,`children_count`) values (1,3,0,0,'0000-00-00 00:00:00','2009-02-20 00:25:34','1',1,0,1),(2,3,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0); insert into `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,32,0,2,1),(2,3,32,1,2,1); insert into `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,31,0,1,'Root Catalog'),(2,3,33,0,1,'root-catalog'),(3,3,31,0,2,'Default Category'),(4,3,39,0,2,'PRODUCTS'),(5,3,33,0,2,'default-category');//Delete product reviews & ratings
truncate table `rating_option_vote`; truncate table `rating_option_vote_aggregated`; truncate table `review`; truncate table `review_detail`; truncate table `review_entity_summary`; truncate table `review_store`;
//Delete Customers TRUNCATE TABLE `customer_address_entity`; TRUNCATE TABLE `customer_address_entity_datetime`; TRUNCATE TABLE `customer_address_entity_decimal`; TRUNCATE TABLE `customer_address_entity_int`; TRUNCATE TABLE `customer_address_entity_text`; TRUNCATE TABLE `customer_address_entity_varchar`; TRUNCATE TABLE `customer_entity`; TRUNCATE TABLE `customer_entity_datetime`; TRUNCATE TABLE `customer_entity_decimal`; TRUNCATE TABLE `customer_entity_int`; TRUNCATE TABLE `customer_entity_text`; TRUNCATE TABLE `customer_entity_varchar`;
How to delete test orders in magento?
SET FOREIGN_KEY_CHECKS=0; TRUNCATE `sales_order`; TRUNCATE `sales_order_datetime`; TRUNCATE `sales_order_decimal`; TRUNCATE `sales_order_entity`; TRUNCATE `sales_order_entity_datetime`; TRUNCATE `sales_order_entity_decimal`; TRUNCATE `sales_order_entity_int`; TRUNCATE `sales_order_entity_text`; TRUNCATE `sales_order_entity_varchar`; TRUNCATE `sales_order_int`; TRUNCATE `sales_order_text`; TRUNCATE `sales_order_varchar`; TRUNCATE `sales_flat_quote`; TRUNCATE `sales_flat_quote_address`; TRUNCATE `sales_flat_quote_address_item`; TRUNCATE `sales_flat_quote_item`; TRUNCATE `sales_flat_quote_item_option`; TRUNCATE `sales_flat_order_item`; TRUNCATE `sendfriend_log`; TRUNCATE `tag`; TRUNCATE `tag_relation`; TRUNCATE `tag_summary`; TRUNCATE `wishlist`; TRUNCATE `log_quote`; TRUNCATE `report_event`; ALTER TABLE `sales_order` AUTO_INCREMENT=1; ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1; ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1; ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1; ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1; ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1; ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1; ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1; ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1; ALTER TABLE `sales_order_int` AUTO_INCREMENT=1; ALTER TABLE `sales_order_text` AUTO_INCREMENT=1; ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1; ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1; ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1; ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1; ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1; ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1; ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1; ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1; ALTER TABLE `tag` AUTO_INCREMENT=1; ALTER TABLE `tag_relation` AUTO_INCREMENT=1; ALTER TABLE `tag_summary` AUTO_INCREMENT=1; ALTER TABLE `wishlist` AUTO_INCREMENT=1; ALTER TABLE `log_quote` AUTO_INCREMENT=1; ALTER TABLE `report_event` AUTO_INCREMENT=1;
How to setup unique prefix For Orders, Invoices, Shipments, Customers and Quotes in magento?
* Orders (set prefix to begin with “O″)
* Invoices (set prefix to begin with “I″)
* Shipments (set prefix to begin with “S″)
* Customers (set prefix to begin with “C″)
* quotes (set prefix to begin with “Q″)
* Invoices (set prefix to begin with “I″)
* Shipments (set prefix to begin with “S″)
* Customers (set prefix to begin with “C″)
* quotes (set prefix to begin with “Q″)
//For Orders update `eav_entity_store` set `increment_prefix`= 'O' where `entity_type_id`='4' and `store_id`='1'; update `eav_entity_store` set `increment_last_id`= '000000000' where `entity_type_id`='4' and `store_id`='1'; //For Invoice update `eav_entity_store` set `increment_prefix`= 'I' where `entity_type_id`='18' and `store_id`='1'; update `eav_entity_store` set `increment_last_id`= '000000000' where `entity_type_id`='18' and `store_id`='1'; //For shipments update `eav_entity_store` set `increment_prefix`= 'S' where `entity_type_id`='24' and `store_id`='1'; update `eav_entity_store` set `increment_last_id`= '000000000' where `entity_type_id`='24' and `store_id`='1'; //For Customers update `eav_entity_store` set `increment_prefix`= 'C' where `entity_type_id`='1' and `store_id`='1'; update `eav_entity_store` set `increment_last_id`= '000000000' where `entity_type_id`='1' and `store_id`='1'; //For quotes update `eav_entity_store` set `increment_prefix`= 'Q' where `entity_type_id`='11' and `store_id`='1'; update `eav_entity_store` set `increment_last_id`= '000000000' where `entity_type_id`='11' and `store_id`='1';
Monday, August 8, 2011
Show new product attribute on the category page list.phtml in magento
Update layout xml (catalog.xml)
add the below code in list.phtml file
also you can useYourAttributeCode YourAttributeCode
Update template (catalog/product/list.phtml)instead of YourAttributeCode
YourAttributeCode
add the below code in list.phtml file
$_helper->productAttribute($_product, $_product->myAttribute(), 'my_attribute');
How change default Home page url to any page url in Magento?
Goto
System -> Configuration -> Web -> Default Pages
and change
Default Web URL From cms to catalog/category/view/id/your CATEGORY ID
Example:
Default Web URL = catalog/category/view/id/123
You can also use any other url.
System -> Configuration -> Web -> Default Pages
and change
Default Web URL From cms to catalog/category/view/id/your CATEGORY ID
Example:
Default Web URL = catalog/category/view/id/123
You can also use any other url.
Categories are not showing up in magento home page
- Make sure you created categories under Default root category.
- Make sure all the categories are active. Inactive ones will be grayed-out. If a toplevel category is inactive the ones below do not show.
- Make sure your category products are,
- status - enabled
- visibility - catalog,search
- Stock Availability - In stock
- websites - your website
- categories - select your category
- Go to System > Manage Stores
- Click the “Main Website Store” link under Store Name
- Make sure the dropdown for “Root Category *” is set to you top level catergory.
- Now clear the cache.
Thats it. Now you can see categories in your homepage.
- Make sure all the categories are active. Inactive ones will be grayed-out. If a toplevel category is inactive the ones below do not show.
- Make sure your category products are,
- status - enabled
- visibility - catalog,search
- Stock Availability - In stock
- websites - your website
- categories - select your category
- Go to System > Manage Stores
- Click the “Main Website Store” link under Store Name
- Make sure the dropdown for “Root Category *” is set to you top level catergory.
- Now clear the cache.
Thats it. Now you can see categories in your homepage.
How to show specific category products on home page magento?
Add the below lines in your homepage cms.
{{block type="catalog/product_list" category_id="123" template="catalog/product/list.phtml"}}where 123 is your category id.
Friday, August 5, 2011
Magento: Sort product by 'created date' and 'new from date'
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT); $collection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate)) ->addAttributeToFilter('news_to_date', array('or'=> array( 0 => array('date' => true, 'from' => $todayDate), 1 => array('is' => new Zend_Db_Expr('null'))) ), 'left') ->addAttributeToSort('news_from_date', 'desc') ->addAttributeToSort('created_at', 'desc');
Magento get last login
$customer = Mage::getSingleton('customer/session')->getCustomer(); $log = Mage::getModel('log/customer')->load($customer->getId()); $lastVisited = $log->getLastVisitAt();
Magento find how long customer is inactive?
$customer = Mage::getSingleton('customer/session')->getCustomer(); $log = Mage::getModel('log/customer')->load($customer->getId()); $inctive_time = now() - $log->getLastVisitAt();
How to get magento date and time?
$now = Mage::getModel('core/date')->timestamp(time()); echo date('m/d/y h:i:s', $now);
Subscribe to:
Posts (Atom)