RSS

Category Archives: magento

Magento: How to get attribute name and value?

/**
* get attribute collection
*/
$attribute = $_product->getResource()->getAttribute(‘my_attribute’);
/**
* get attribute type
*/
$attribute->getAttributeType();
/**
* get attribute Label
*/
$attribute->getFrontendLabel();
/**
* get attribute default value
*/
$attribute->getDefaultValue();
/**
* check if the attribute is visible
*/
$attribute->getIsVisible();
/**
* check if the attribute is required
*/
$attribute->getIsRequired();
/**
* get attribute value
*/
$attributeValue = Mage::getModel(‘catalog/product’)->load($_product->getId())->getMyAttribute();

 

Get value from a select box attribute

The attribute code is supposed to be ‘my_attribute

Load any particular attribute by attribute code

Get all option value list for the particular attribute

You can see above that I got attribute information by attribute code. My attribute information is stored as $attributeInfo. See code above.

Here is the code to get all option values for my attribute $attributeInfo.

Get all options of any attribute

Getting all options of attribute with attribute-code “color“.

Get attribute’s option information by option id

I have my attribute as $attributeInfo.
I have my attribute’s option value array as $attributeOptions.
See code above.

Suppose, I want to get detail information of any option listed in strong>$attributeOptions array. Here is the code to do so:-

Get attribute of particular entity type

Here, I am going to get information about ‘order_id‘ attribute of ‘invoice‘ entity type.

Get attribute options of Configurable product

Hope this helps. Thanks.

soruce From:http://blog.chapagain.com.np/magento-how-to-get-attribute-name-and-value/

Advertisements
 
Leave a comment

Posted by on July 2, 2015 in magento

 

Magento database maintenance

Log cleaning

Magento maintains several tables for logging. These tables log things such as customer accesses and frequently-compared products. Magento has a mechanism for cleaning these logs regularly, but unfortunately, this feature is disabled by default and most customers do not enable it. There are three ways to clean out these tables: via log cleaning in the Magento Admin, via log.php in the ../shell directory, and manually via phpMyAdmin or MySQL client.

The following tables are managed by Magento’s log cleaning function:

log_customer

log_visitor log_visitor_info
log_url log_url_info
log_quote
report_viewed_product_index
report_compared_product_index
report_event catalog_compare_item
Log cleaning via administrator interface
  • From the Magento administrator interface, go to System > Configuration.
  • In the left menu under Advanced, click System.
  • Under Log Cleaning, change Enable Log Cleaning to Yes and configure the Save Log for 15 days:
log_cleaning01
  • Click Save Config

 

Manual cleaning via phpMyAdmin

This is the most efficient way to clean the logs for those more comfortable working with databases. It is faster than the built-in Magento tools and it allows you to clean other tables not included in those tools. This procedure will consolidate the data inside those tables, often decreasing database size by as much as 95% and greatly reducing query times.

  1. Open the database in phpMyAdmin via the SiteWorx control panel.
  2. In the right frame, select the check box for the following tables:
dataflow_batch_export
dataflow_batch_import
log_customer
log_quote log_summary
log_summary_type
log_url log_url_info
log_visitor log_visitor_info
log_visitor_online
report_viewed_product_index
report_compared_product_index
report_event
log_cleaning02
  • At the bottom of the page, click the drop-down box With Selected and select Empty.
  • A confirmation screen will appear. Click Yes. This will truncate all of the selected tables.
  • Click the Structure tab at the top of the page.
  • Select the same tables as you did in step 2, then under the With Selected drop-down menu, select Optimize.

Regular maintenance

It is not unusual to see 2GB+ databases decrease their size by 75% after cleaning the logs. It is therefore critical to regularly perform this sort of maintenance, particularly if your time-to-first-byte latency begins increasing and you have already implemented the other performance tweaks.

http://eaccelerator.net/

 
Leave a comment

Posted by on November 11, 2014 in magento

 

Add to Cart not working in Chrome and Firefox

And did #3 and it worked.

I logged in to my FTP then went to: Magento Folder/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php

and commented out the following that starts at about line 78 as you see below.

/*
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
);
*/

 
Leave a comment

Posted by on April 24, 2014 in magento

 

Database server does not support the innodb storage engine

magento_db_connection_error

If you are trying to install older versions of Magento on MySQL 5.6.x you are most likely getting either “Database connection error” or “Database server does not support the InnoDB storage engine.” (depends on the version of Magento). This short post is about why this is happening and how you can fix it.

The error is happening because MySQL system variable “have_innodb” has been deprecated in version 5.6.1. Here’s the link to the official documentation: http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_have_innodb.

If you take a look at /app/code/core/Mage/Install/Model/Installer/Db.php you will notice that there is an “if” statement to check if your system has InnoDB engine supported. For example, in Magento CE 1.5.0.1 it looks like this:

// check InnoDB support
if (!isset($variables[‘have_innodb’]) || $variables[‘have_innodb’] != ‘YES’) {
Mage::throwException(Mage::helper(‘install’)->__(‘Database server does not support the InnoDB storage engine.’));

…and in Magento 1.7.0.2 it’s something like this:

// check InnoDB support
if (!$resource->supportEngine()) {
Mage::throwException(
Mage::helper(‘install’)->__(‘Database server does not support the InnoDB storage engine.’)
);
}

Magento Installation: Database connection error
November 28th, 2013 by Nikola Stojiljkovic in Backend, Bugs, Database, Magento 0
magento_db_connection_error

If you are trying to install older versions of Magento on MySQL 5.6.x you are most likely getting either “Database connection error” or “Database server does not support the InnoDB storage engine.” (depends on the version of Magento). This short post is about why this is happening and how you can fix it.

The error is happening because MySQL system variable “have_innodb” has been deprecated in version 5.6.1. Here’s the link to the official documentation: http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_have_innodb.

If you take a look at /app/code/core/Mage/Install/Model/Installer/Db.php you will notice that there is an “if” statement to check if your system has InnoDB engine supported. For example, in Magento CE 1.5.0.1 it looks like this:

1
2
3

// check InnoDB support
if (!isset($variables[‘have_innodb’]) || $variables[‘have_innodb’] != ‘YES’) {
Mage::throwException(Mage::helper(‘install’)->__(‘Database server does not support the InnoDB storage engine.’));

…and in Magento 1.7.0.2 it’s something like this:

1
2
3
4
5
6

// check InnoDB support
if (!$resource->supportEngine()) {
Mage::throwException(
Mage::helper(‘install’)->__(‘Database server does not support the InnoDB storage engine.’)
);
}

To resolve the issue, you can comment out this “if” statement and proceed with installation. Once the installation is complete revert the changes you have made to the file. (Besause there is a special place in hell for those who modify Magento’s core files. 🙂 )

http://leaditsoftware.com/blog/magento-installation-database-connection-error/

 
Leave a comment

Posted by on February 13, 2014 in magento

 

Use a Content Delivery Network (CDN)

There are free cdn for the website

https://www.cloudflare.com/

 

 
Leave a comment

Posted by on August 13, 2013 in magento

 

Why I can not login to magento backend using google chrome

There are two solution for this,any one of can work ,
ANfkr

Go to app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file within your magento directory.

Find the code:
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath(),
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
);

and replace with

session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);

After this save the file.

For me the second solution worked.

another way

If you enabled the https for the Magento admin panel, then make sure to set “NO” for the option “Use HTTP Only” under System->configuration->web->Session and Cookie Management.”

If you have access to the database then open the table “core_config_data” and search for the Path “web/cookie/cookie_httponly” and set the value to “0”.

Make sure to delete the var/cache folder. Now try to login to Magento admin panel. Mostly you can now. If not post your issue in this thread.

So this “Not able to login Magento admin panel” issue mostly relates to the Magento cookies settings. So don’t get worried if you encounter this tiny issue. With the list of answers in this thread you can easily sort this out in a few minutes time.

 
Leave a comment

Posted by on August 13, 2013 in magento

 

Manage Category, Customer and Customer Address Attributes

Manage Category, Customer and Customer Address Attributes

direct link

http://connect20.magentocommerce.com/community/Hwg_Attributemanager

 

2nd

http://www.magentocommerce.com/magento-connect/medma-category-attribute-3805.html

 

 
Leave a comment

Posted by on July 25, 2013 in magento