How to run direct MySQL Queries in Magento
While developing custom solutions for Magento, developers should always think about performance. There are many areas that we can focus on: block caching and removing unnecessary blocks from layout, disabling unused modules, database-related optimisation. Let's talk about the database-related optimisation, about direct SQL queries in particular.
Labels:
Magento
How to create an attribute field for customer account in Magento
Labels:
Magento
How to enable tempalte and block path hints in Magento
Run this query in your database.
INSERT INTO core_config_data (scope, scope_id, path,value)
VALUES ('default', 0, 'dev/debug/template_hints', 1),
('default', 0, 'dev/debug/template_hints_blocks', 1);
To disable them again, run this query:
UPDATE core_config_data set value = 0 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints'
To enable again run this query:
UPDATE core_config_data set value = 1 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints'
INSERT INTO core_config_data (scope, scope_id, path,value)
VALUES ('default', 0, 'dev/debug/template_hints', 1),
('default', 0, 'dev/debug/template_hints_blocks', 1);
To disable them again, run this query:
UPDATE core_config_data set value = 0 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints'
To enable again run this query:
UPDATE core_config_data set value = 1 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints'
Labels:
Magento
How to update inventory, Price using custome attribute in magento
Labels:
Magento
How to get Controller, Module, Action & Router Name in Magento
In most of the case you need to know
the name of controller or module in order to debug. Simple one line code to get
these.
1. Get Controller Name In Template
Files:
$this->getRequest()->getControllerName();
2. Get Action Name In Template
Files:
$this->getRequest()->getActionName(); //the function inside the controller
3. Get Router Name In Template
Files:
$this->getRequest()->getRouteName();
Labels:
Magento
Change Base url in magento using database.
How to change Unsecure “base url” and Secure “Base url” In magento
using databse.
1.
Open Database and find “core_config_data”
table. In this table find “web/unsecure/base_url” and
“web/secure/base_url” under “Path” column.
2.
Under value column change your desire url.
3.
Save data
Finsish
Labels:
Magento
Newsletter auto-subscribe on create account and place order in Magento
By default Magento provides a Newsletter feature, which enables store
administrators to send newsletters to customers who have registered to receive
them. Since most customers tend not to opt-in to any email subscription related
services, you might need to automatically subscribe customers when they
register or place an order. In this article I’ll present code and simple
Magento extension to make it easier for you to accomplish this task.
Labels:
Magento
How to Add a ‘New Product’ Icon in Magento for New Products
1. Manage attributes
Go to Catalogue -> Attributes
-> Manage Attributes. Set up a new attribute at this page and call it
‘Boolean’. Set its ID as new_product. Under your advanced options, you will
have the option to select it as a front end product. Do this. Now you simply
have to add the new attribute to your custom attribute if you are using one. If
not, set it to default. Save the new product.
You will now have a new product in
your catalogue which has a Boolean flag set to yes. The next stage involves
taking this new product icon and putting it in your front end.
2.
Make it show
Now that you have a product icon
with a Boolean flag, it’s time to make this show on your front end. This is
achieved by accessing template files: templates/catalog/product/list.phtml and
templates/catalog/product/view/media.phtml.
<div
class="product-image">
<?php
if($_product->getNewProduct()) { ?>
<div
class="new-product"></div>
<?php } ?>
<?php
$_img = '<img
id="image" src="'.$this->helper('catalog/image')
->init($_product,
'image').'"
alt="'.$this->htmlEscape($this->getImageLabel()).'"
title="'.$this->htmlEscape($this->getImageLabel()).'"
/>';
echo
$_helper->productAttribute($_product, $_img, 'image');
?>
</div>
As you can see, above, your new
product is shows in ‘$_product->getNewProduct’. The next step is to ensure
that your CSS is set up to show your product with Boolean flag. You need to
make the product_class relative to the position of the icon. So:
.products-grid .product-image {
position: relative; display:block; width:244px; height:156px; margin:0 0 10px;
}
.new-product {
position: absolute;
right: 0;
top: 0;
width: 65px;
height: 66px;
display: block;
z-index: 2;
background: url(../images/new-product.png)
no-repeat;
3.
Save
Save your changes and ensure that
your code is correct before doing so. Now, every time you add a new product and
it goes on sale through your front end, it’ll have an icon and Boolean flag.
Labels:
Magento
Subscribe to:
Posts (Atom)