Reset use secure in front end in database magento

Share
Posted on May 14th, 2013 | Posted by admin

I ran into an issue this week where I switched on SSL on a development site and then realized the SSL cert was not installed correctly. This is a big issue in Magento because there is no way to get back to the admin to switch it back off.

If this ever happens do the following to switch back:

1. Open up your admin panel (cPanel or other)
2. Go to phpMyAdmin (if MySql)
3. Find your Magento Database
4. Find table “core_config_data”
5. Look for the columns “web/secure/use_in_frontend” and “web/secure/use_in_adminhtml”
6. Edit both values, make them equal to “0″

After this is done you will be back in action.

How to get product id from the current product page

Share
Posted on May 13th, 2013 | Posted by admin

I wanted to implement a way that products images in magento could be able to have link to open a popup when the image is clicked to show a larger image in a separate browser window
for that we would need the product id to send it with the link url and receive it by get method there
I dont want to intruct the way we would show the product instead I want to show you how to get the current product id to send it with the url let say
ur/file.php?id=884

$product_id = $this->getProduct()->getId();

or if you could not able to use $this instead of the above you can use

$product_id = Mage::registry(‘current_product’)->getId();

Database Queries in magento

Share
Posted on May 11th, 2013 | Posted by admin

Magento is a complete and awesome MVC application. It’s fully moduler and easy to extend its features and functionality. All the CRUD operations are performed using the modules, model classes. But many a time it requires a developer to execute the db query in traditional form.

Here is the list of methods and queries.

In magento to Read or Write any query we need database connection.

<?php
//database read adapter
$read = Mage::getSingleton('core/resource')->getConnection('core_read')
//database write adapter
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
?>

These connections return special instances of the Mage_Core_Model_Resource class, that contains functions used to execute raw Database Queries.

Magento custom form validation

Share
Posted on May 8th, 2013 | Posted by admin

Custom validation method

Adding a new validation rule into a form in Magento is easy as adding a “required” class for a input form. While existing validation rules can be seen in file js/prototype/prototype.js there is an easy way to add your own validation rule.

Add following inline JavaScript into template or load it in separate file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<script type="text/javascript">
//<![CDATA[
Validation.add('required-classname','<?php echo __('Please enter valid value.'); ?>',function(value){
if(value == null)
{
return false;
}
/*
* Your code here
* Return true if you like the value
*/
});
//]]>
</script>

First parameter is the classname for your input element. The second parameter is the error message for invalid input. Third parameter is a function where your code lies. The function should return false on invalid value.

Adding a ‘New Product’ icon in Magento for new products

Share
Posted on April 19th, 2013 | Posted by admin

This is actually quick and easy but if you are new to Magento custom attributes you might struggle to work out how to set things up and then access the value of your attribute on the front end.

What I am talking about here is setting up a flag for the product, if it’s set to ‘Yes’ (ie the product is a new product) then a little icon or banner appears in the corner of the image.
You need to set up a new Attribute in Catalogue -> Attributes -> Manage Attributes . Set is as a boolean, give it an id of new_product. Make it available on the front end product view (one of the advanced options). Now add the attribute to your custom attribute set if your using one, or the default set if you are not. Go in and set it to ‘Yes’ for your product and save it.

So we’ve got a product in the Magento catalogue which has a boolean flag set to yes for the attribute ‘new_product’. How do we then access that an display it on the front end? Easy.

Page 10 of 95« First...«89101112»203040...Last »