Just to keep things tidy!
SELECT attribute_id, attribute_code, frontend_label
FROM eav_attribute
WHERE entity_type_id = 4
AND attribute_id NOT IN(SELECT attribute_id FROM eav_entity_attribute);
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 s.attribute_set_name,
g.attribute_group_name,
a.attribute_code,
a.frontend_label,
ea.sort_order
FROM eav_attribute_set s
LEFT JOIN eav_attribute_group g ON s.attribute_set_id = g.attribute_set_id
LEFT JOIN eav_entity_attribute ea ON g.attr...
This is because you've missed out _product_websites
, for which all products should have a value of base
Ok so to import images you first need these columns:
_media_attribute_id
- the attribute_id of media_gallery
(see below)_media_image
- the path of the image, i.e. /some_image.jpg
_media_lable
- the image label, i.e. "My nice image"_media_position
- the position, 1, 2 etc_media_is_disabled
- whether the image is excluded from the gallery or notYou do the whole weird multi-line thing to import multiple images. Every image
you use (whether it's in the gallery, or being used for the image
, small_image
or `thumbn...
<!-- # Module Initialisation
app/etc/modules/Namespace_ModuleName.xml -->
<config>
<modules>
<Namespace_ModuleName>
<active>true</active>
<codePool>local</codePool>
</Namespace_ModuleName>
</modules>
</config>
<!-- # Module Configuration
app/code/local/Namespace/ModuleName/etc/config.xml -->
<config>
<modules>
<Nmespace_ModuleName>
<version>0.0.1</version>
</Nmespace_ModuleName>
...
<config>
<global>
<helpers>
<catalog>
<rewrite>
<data>Namespace_Module_Helper_Catalog_Data</data>
</rewrite>
</catalog>
</helpers>
</global>
</config>
<config>
<global>
<blocks>
<catalog>
<rewrite>
<product>Namespace_Module_Block_Catalog_Product</product>
</rewrite>
</catalog>
</blocks>
</global>
</config>
<config>
<global>
<helpers>
<namespace_module>
<class>Namespace_Module_Helper</class>
</namespace_module>
</helpers>
</global>
</config>
Yeh it's not Magento, but this might help some people:
Zend_Debug::dump()
Basically it's var_dump but with <pre>
tags, no biggie but it's nice to use.
Name:
Mage::getStoreConfig('general/store_information/name')
Phone number:
Mage::getStoreConfig('general/store_information/phone')
Address:
Mage::getStoreConfig('general/store_information/address')
E-Mail:
Mage::getStoreConfig('trans_email/ident_general/email')
public function getCategories()
{
if (!$this->categories) {
$categoryId = $this->getData('parent_category_id');
$parentCategory = Mage::getModel('catalog/category')->load($categoryId);
$categoryCollection = $parentCategory->getCollection();
$categoryCollection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('image')
->addAttributeToFilter('is_active', 1)
->addAttributeToFilte...
public function getCategoryImage(Mage_Catalog_Model_Category $category, $width = 250, $height = 250)
{
// return when no image exists
if (!$category->getImage()) {
return false;
}
// return when the original image doesn't exist
$imagePath = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category'
. DS . $category->getImage();
if (!file_exists($imagePath)) {
return false;
}
// resize the image if needed
$rszImagePat...
/**
* Yourcompany.com
*
* PHP Version 5
*
* @category Namespace
* @package Namespace_Module
* @author Your Name <your.name@yourcompany.com>
* @copyright 2012 yourcompany.com
* @license http://www.yourcompany.com/license.txt Your license
* @link N/A
*/
/**
* Something resource collection model
*
* @category Namespace
* @package Namespace_Module
* @author Your Name <your.name@yourcompany.com>
* @license http://www.yourcompany.com/lice...
/**
* Yourcompany.com
*
* PHP Version 5
*
* @category Namespace
* @package Namespace_Module
* @author Your Name <your.name@yourcompany.com>
* @copyright 2012 yourcompany.com
* @license http://www.yourcompany.com/license.txt Your license
* @link N/A
*/
/**
* Something resource model
*
* @category Namespace
* @package Namespace_Module
* @author Your Name <your.name@yourcompany.com>
* @license http://www.yourcompany.com/license.txt You...
Much easier to show how this is done by showing you some code examples, so please see the link attached.
The various types are:
See the link for detailed usage information
Use this syntax:
Translator.translate('Some phrase');
I believe you also have to make the translation available to the Translate class in this manner:
<script type="text/javascript">
Translator.add('You should take care of this confirmation message!','<?php echo Mage::helper('yourmodule')->__('You should take care of this confirmation message!')?>');
</script>
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 about 25 of them, I decided to just list the popular ones, enjoy.
Output example (shortened):
|----------------------------------+----------+----------+---------------------|
| attribute_code | type | store_id | value |
|----------------------------------+-----...
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$collection->addAttributeToSelect($attributes);
Declare an admin layout XML file for your module in your config.xml
:
<config>
<adminhtml>
<layout>
<updates>
<your_module>
<file>your-module.xml</file>
</your_module>
</updates>
</layout>
</adminhtml>
</config>
Create the layout XML in /app/design/adminhtml/default/default/layout/your-module.xml
:
<?xml version="1.0"?>
<layout>
<adminhtml_catalog_product_edit>
<refer...
Declare an admin layout XML file for your module in your config.xml:
Create the layout XML in /app/design/adminhtml/default/default/layout/your-module.xml:
Handy link to a very useful PDF which details how to handle multiple databases in Magento.
The attached link describes everything fantastically, just go there.