Technical Lead -Magento, PHP & MySql , Hybrid Mobile App development

Undo the Cancel order in magento using coding

A Magento order could be cancelled by mistake, but there is no way to undo this action – at least not in the GUI.  write just a simple PHP-script to accomplish  task.

 

<?php
required_once ‘app/Mage.php’;
Mage::app();

$order = Mage::getModel(‘sales/order’)->load(1382);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE);
$order->setStatus(Mage_Sales_Model_Order::STATE_COMPLETE);
$order->save();

foreach ($order->getAllItems() as $item) {
$item->setQtyCanceled(0);
$item->save();
}

4 Ways to check Magento Versions without code

4 Ways to check Magento Versions without code

Adding new custom image attribute to category in dashboard

Magento : Add custom image attribute to category
Magento : Add custom image attribute to category

Just copy paste the below code in header.phtml and run yourmagento once, your attribute will be created and you can see in backend under manage category. After you are done remove this code again.

——————————————————————————————
$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);

$setup->addAttribute(‘catalog_category’, ‘sliderimage’, array(
‘group’ => ‘General’,
‘input’ => ‘image’,
‘type’ => ‘varchar’,
‘label’ => ‘Slider Image’,
‘backend’ => ‘catalog/category_attribute_backend_image’,
‘visible’ => 1,
‘required’ => 0,
‘user_defined’ => 1,
‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

Its works, Thanks to Afroz Alam http://developerafroz.blogspot.in/

how to find the mysql hostname in terminal(SSH)

If you want to know the port number of your local host on which Mysql is running you can use this query on MySQL Command line client —

SHOW VARIABLES WHERE Variable_name = ‘port’;

mysql> SHOW VARIABLES WHERE Variable_name = ‘port’;

+—————+——-+

| Variable_name | Value |

+—————+——-+

| port          | 3306  |

+—————+——-+

1 row in set (0.00 sec)

It will give you the port number on which MySQL is running.

If you want to know the hostname of your Mysql you can use this query on MySQL Command line client —

SHOW VARIABLES WHERE Variable_name = ‘hostname’;

mysql> SHOW VARIABLES WHERE Variable_name = ‘hostname’;

+——————-+——-+

| Variable_name     | Value |

+——————-+——-+

| hostname          | Dell  |

+——————-+——-+

1 row in set (0.00 sec)

It will give you the hostname for mysql.

If you want to know the username of your Mysql you can use this query on MySQL Command line client —

select user();   

mysql> select user();

+—————-+

| user()         |

+—————-+

| root@localhost |

+—————-+

1 row in set (0.00 sec)

default-username = root password = you-know-it-better url for localhost = jdbc:mysql://localhost default-port = 3306

    For example, you can try:

//If you want to get user, you need start query in your mysql:

SELECT user(); // output your user: root@localhost

SELECT system_user(); // —

//If you want to get port your “mysql://user:pass@hostname:port/db”

SELECT @@port; //3306 is default

//If you want hostname your db, you can execute query

SELECT @@hostname;

mysql> SHOW VARIABLES WHERE Variable_name = ‘hostname’;

+—————+———–+

| Variable_name | Value     |

+—————+———–+

| hostname      | karola-pc |

+—————+———–+

1 row in set (0.00 sec)

Hope it will Help you to understand

To enable gZip in Magento 1.9

Kindly include the following code inside the .htaccess file

 <IfModule mod_headers.c>
# YEAR
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$">
Header set Cache-Control "max-age=29030400"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# 45 MIN
<FilesMatch "\.(html|htm|txt)$">
Header set Cache-Control "max-age=86400"
</FilesMatch>
</IfModule>

<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl|asp|html)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>

 

Manually Changing Domain in Magento

How to Manually Change Domain in Magento

  1. Update your core_config_data table to edit the two records for web/unsecure/base_urland web/secure/base_url
  2. Delete the contents of WEBROOT/var/cache
  3. Update / edit any .htaccess domain redirects you may have added
  4. Restart Apache
  5. Make sure Apache has write permissions to WEBROOT/var
  6. If you created a new DB, ensure that the WEBROOT/app/etc/local.xml is pointing to it.
  7. If you’re using Chrome, clear your browser cache! (Chrome caches 301s)

You can remove the index.php in the frontend URLs performing the following steps:

Go to the admin section of Magento.

  1. In System -> Configuration -> Web -> Search Engines Optimizations, select YES.
  2. In System -> Configuration -> Web -> Secure -> Use secure URLs in the frontend, select YES.
  3. Edit the /installdir/apps/magento/htdocs/.htaccess and uncomment the line:

    RewriteBase /magento/

Redirection conditions for contact form 7 in wordpress

I found an answer :  Redirecting without a condition When you use the WordPress plugin “Contact Form 7” you can redirect the user to another page after submitting the answers by the following code:  on_sent_ok: “location.replace(‘http://www.website1.com&#8217;);”

The line of code you have to copy into the “settings” box at the end of a specific form you created.  Redirecting on a condition If you want to make the redirecting depending on a specific answer, you can use the following code:  on_sent_ok: ” if (document.getElementById(‘field’).value==’yes’) {location.replace(‘http://www.website1.com&#8217;)} else { location.replace(‘http://www.website2.com/&#8217;) } “

The code in bold letters has to be changed by your settings.  For example: The question with the id “field” has two possible answers: “Yes” or “No”. If a person selects “Yes” he or she should be redirected to “http://www.website1.com”. If “No” is selected, the user should be redirected to “http://www.website2.com/”.