Add All Attributes To A Collection
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$collection->addAttributeToSelect($attributes);
Related cards:
Fetching All Attributes For An Entity From The DB In One Query
Using the database to inspect EAV-based entity types can be a real pain in the ass, so here are a bunch of queries that let you inspect some popular EAV entity types easily. This practice can be applied to any EAV entity type, however as there are...
Adding Attribute To Category List Product Collection
Only a core set of attributes are added to the product collection (for the list page) by default. This bit of XML will allow you to add additional attributes to that collection:
<config>
<frontend>
<product>
...
Product Attribute Addition
This code shows all possible configuration options for an attribute that I know of, you need not include all of these when adding an attribute (although it won't hurt)
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
...
Many to Many Resource Model Mapping
This is some boilerplate code to facilitate the use of many-to-many relationship tables in Magento. I found myself rewriting this code often, so this saves some time. This example links a sizeguide entity to attribute sets. Obviously you'll need t...
Adding Attributes To Other Entities With getDefaultEntities()
Don't do it!! I did the below:
public function getDefaultEntities()
{
return array(
'catalog_product' => array(
'attributes' => array(
'size_guide_id' => array(
...
Add Category Attributes Through SQL Updates
This is creating a module which will update categories to include new attributes.
-
inside app/etc/modules/yourmodule.xml put the following:
<?xml version="1.0"?> <config> <modules> <Yourmodule_Sql>...
Add A Tab To The Admin Product Screen
Declare an admin layout XML file for your module in your config.xml
:
<config>
<adminhtml>
<layout>
<updates>
<your_module>
<file>your-module.xml</file>
...
Allowing Import Of Invisible Attributes
By setting a Product Attribute to be invisible via the visible
property, you stop the ability to import that attribute unless you alter the _forcedAttributesCodes
property of...
Product EAV Attribute Set, Group and Attribute List
To see a list of all attribute sets, groups, and associated attributes for products, use this SQL. BONUS! Also shows the sort ordering, useful for determining which sort_order
you need to place an attribute in a certain position:
SELECT...
Dataflow Per-Store Import Causing Copy of All Attributes
Fancy importing a subset of some product attributes on a per-store basis, whilst keeping the attributes that weren't imported using the defaults?
Tough, you can't!
Well, not with dataflow anyway. [This card](https://makandracards.com/magento...