Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Creating image classes like Base Image, Small Image, Thumbnail
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

I know that I saw a post about how to do this somewhere on these forums but I have been through over 20 pages of the Programming forum and the How Do I forum with no luck ...

Does anyone know how to create additional image classes in the admin like the Base Image, Small Image, Thumbnail - or has anyone bookmarked that thread since I apparently didn’t?

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Ok I’m creating a class called Gallery 1, so far I have added:

app/code/core/Mage/Catalog/Helper/Product.php line 94

/**
     * Retrieve gallery1 image url
     *
     * @return string
     */
    public function getGallery1Url($product)
    
{
        $url 
false;
        if (!
$product->getGallery1()) {
            $url 
Mage::getDesign()->getSkinUrl('images/no_image.jpg');
        
}
        
elseif ($attribute $product->getResource()->getAttribute('gallery1')) {
            $url 
$attribute->getFrontend()->getUrl($product);
        
}
        
return $url;
    
}

app/code/core/core/Mage/Catalog/Model/Layer.php line 72

->addAttributeToSelect('gallery1')

app/code/core/Mage/Catalog/Model/Product.php line 770

public function getGallery1Url()
    
{
        
return $this->_urlModel->getGallery1($this);
    
}

    
public function getCustomGallery1Url($size$extension=null$watermark=null)
    
{
        
return $this->_urlModel->getCustomGallery1($this$size$extension$watermark);
    
}

app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php line 66

protected $_imageFields = array(
        
'image''small_image''thumbnail''gallery1'
    
);

app/code/core/Mage/Catalog/Model/Convert/Parser/Product.php line 50

protected $_imageFields = array(
        
'image''small_image''thumbnail''gallery1'
    
);

app/code/core/Mage/Catalog/Model/Product/Url.php line 154

public function getGallery1Url($product)
    
{
        $url 
false;
        if (!
$product->getGallery1()) {
            $url 
Mage::getDesign()->getSkinUrl('images/no_image.jpg');
        
}
        
elseif ($attribute $product->getResource()->getAttribute('gallery1')) {
            $url 
$attribute->getFrontend()->getUrl($product);
        
}
        
return $url;
    
}

    
public function getCustomGallery1Url($product$size$extension=null$watermark=null)
    
{
        $url 
false;
        if (
$attribute $product->getResource()->getAttribute('gallery1')) {
            $url 
Mage::getModel('media/image')
                    ->
setConfig(Mage::getSingleton('catalog/product_media_config'))
                    ->
getSpecialLink($attribute$size$extension$watermark);
        
}
        
return $url;
    
}

app/code/coreMage/Catalog/Model/Resource/Eav/Mysql4/Setup.php line 793

'gallery1' => array(
                        
'group'             => 'Images',
                        
'type'              => 'varchar',
                        
//'backend'           => 'catalog/entity_product_attribute_backend_image',
                        
'frontend'          => 'catalog/product_attribute_frontend_image',
                        
'label'             => 'Gallery 1',
                        
'input'             => 'media_image',
                        
'class'             => '',
                        
'source'            => '',
                        
'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
                        
'visible'           => true,
                        
'required'          => false,
                        
'user_defined'      => false,
                        
'default'           => '',
                        
'searchable'        => false,
                        
'filterable'        => false,
                        
'comparable'        => false,
                        
'visible_on_front'  => false,
                        
'unique'            => false,
                    ),

app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-0.7.13-0.14.php line 29

(int) $installer->getAttributeId('catalog_product''gallery1'),

app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-0.7.8-0.7.9.php line 33

$installer->updateAttribute('catalog_product''gallery1''frontend_input''media_image');

app/code/core/Mage/CatalogSearch/Helper/Data.php line 136

case 'gallery1':
                return 
$this->getGallery1Url($product);

app/code/core/Mage/Tag/Block/Product/Result.php line 80

->addAttributeToSelect('gallery1')
 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Now ... it doesn’t show up in my admin yet, but it also doesn’t give me any errors.  The frontend, however, gives me this error:

Invalid attribute requestedgallery1
Trace
:
#0 /home/minerva8/public_html/gladrag/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(330): Mage::exception('Mage_Eav', 'Invalid attribu...')
#1 /home/minerva8/public_html/gladrag/app/code/core/Mage/Catalog/Model/Layer.php(74): Mage_Eav_Model_Entity_Collection_Abstract->addAttributeToSelect('gallery1')
#2 /home/minerva8/public_html/gladrag/app/code/core/Mage/Catalog/Model/Layer.php(43): Mage_Catalog_Model_Layer->prepareProductCollection(Object(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection))
#3 /home/minerva8/public_html/gladrag/app/code/core/Mage/Catalog/Block/Product/List.php(64): Mage_Catalog_Model_Layer->getProductCollection()
#4 /home/minerva8/public_html/gladrag/app/code/core/Mage/Catalog/Block/Product/List.php(106): Mage_Catalog_Block_Product_List->_getProductCollection()
#5 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Abstract.php(553): Mage_Catalog_Block_Product_List->_beforeToHtml()
#6 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Model/Email/Template/Filter.php(56): Mage_Core_Block_Abstract->toHtml()
#7 /home/minerva8/public_html/gladrag/lib/Varien/Filter/Template.php(122): Mage_Core_Model_Email_Template_Filter->blockDirective(Array)
#8 /home/minerva8/public_html/gladrag/app/code/core/Mage/Cms/Block/Page.php(75): Varien_Filter_Template->filter(Array, Array)
#9 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Abstract.php(554): Mage_Cms_Block_Page->_toHtml('{{block type="c...')
#10 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Text/List.php(37): Mage_Core_Block_Abstract->toHtml()
#11 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Abstract.php(554): Mage_Core_Block_Text_List->_toHtml()
#12 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Abstract.php(431): Mage_Core_Block_Abstract->toHtml()
#13 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Abstract.php(408): Mage_Core_Block_Abstract->_getChildHtml()
#14 /home/minerva8/public_html/gladrag/app/design/frontend/default/gladrag/template/page/1column.phtml(46): Mage_Core_Block_Abstract->getChildHtml('content', true)
#15 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Template.php(131): include('/home/minerva8/...')
#16 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Template.php(163): Mage_Core_Block_Template->fetchView('content')
#17 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Template.php(180): Mage_Core_Block_Template->renderView('frontend/defaul...')
#18 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Block/Abstract.php(554): Mage_Core_Block_Template->_toHtml()
#19 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Model/Layout.php(505): Mage_Core_Block_Abstract->toHtml()
#20 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Controller/Varien/Action.php(319): Mage_Core_Model_Layout->getOutput()
#21 /home/minerva8/public_html/gladrag/app/code/core/Mage/Cms/Helper/Page.php(77): Mage_Core_Controller_Varien_Action->renderLayout()
#22 /home/minerva8/public_html/gladrag/app/code/core/Mage/Cms/controllers/IndexController.php(26): Mage_Cms_Helper_Page->renderPage()
#23 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Controller/Varien/Action.php(342): Mage_Cms_IndexController->indexAction(Object(Mage_Cms_IndexController), 'home')
#24 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(159): Mage_Core_Controller_Varien_Action->dispatch()
#25 /home/minerva8/public_html/gladrag/app/code/core/Mage/Core/Controller/Varien/Front.php(146): Mage_Core_Controller_Varien_Router_Standard->match('index')
#26 /home/minerva8/public_html/gladrag/app/Mage.php(427): Mage_Core_Controller_Varien_Front->dispatch(Object(Mage_Core_Controller_Request_Http))
#27 /home/minerva8/public_html/gladrag/index.php(43): Mage::run()
#28 {main}

Any help would be GREATLY appreciated!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Stéphane
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2009-01-22
Biot, France
 

Maybe you should have a look to this thread, it might help you regarding this issue.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top