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

Product Saving Issue in Magento v1.5.0.1: Other store view data overwritten to default storeview. 
 
Shozab
Jr. Member
 
Total Posts:  1
Joined:  2011-01-23
 

1) open magento demo store http://demo-admin.magentocommerce.com of 1.5.0.1
2) open any product, select french store view and change product title then save.

Now see the problem,
1) open same product again but in three windows. select default store view in window 1. Select French store view in Window 2.
2) In window 2, press save button without changing any thing.
3) refresh the window 1. You will see that the data of French store will be overwritten to default store view.
This behavior was not in magento 1.3.2.3

 
Magento Community Magento Community
Magento Community
Magento Community
 
jhaagmans
Jr. Member
 
Total Posts:  14
Joined:  2010-08-04
 

I confirm this problem for both versions 1.5.0.1 and 1.5.1. We had to rewrite many product descriptions because of this!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jEzEk CHiCKi
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2011-01-24
 

So, the problem is in “app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Abstract.php” in function _insertAttribute($object, $attribute, $value), row 255. There is a condition: if attribute is required and store is not default store, so insert attribute for default store. This rewrites default values.

To fix this i used code from magento v1.6. After the condition simply check if there is default value and only if there is no default value insert current value.

$table $attribute->getBackend()->getTable();

            
$select $this->_getReadAdapter()->select()
                ->
from($table)
                ->
where('entity_type_id = ?'$attribute->getEntityTypeId())
                ->
where('attribute_id = ?'$attribute->getAttributeId())
                ->
where('store_id = ?'$this->getDefaultStoreId())
                ->
where('entity_id = ?',  $object->getEntityId());
            
$row $this->_getReadAdapter()->fetchOne($select);
                
            if (!
$row{
              
...
              
original code inside condition
             
...
           
}

So this is the bugfix.
the bug-fixed function is here:

/**
     * Insert entity attribute value
     *
     * @param   Varien_Object $object
     * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
     * @param   mixed $value
     * @return  Mage_Eav_Model_Entity_Abstract
     */
    protected function _insertAttribute($object$attribute$value)
    
{
        
/**
         * save required attributes in global scope every time if store id different from default
         */
        
$storeId Mage::app()->getStore($object->getStoreId())->getId();
        if (
$attribute->getIsRequired() && $this->getDefaultStoreId() != $storeId{
            
// bugfix for updating default values from 1.6
            // first see if there is a default value
            
$table $attribute->getBackend()->getTable();

            
$select $this->_getReadAdapter()->select()
                ->
from($table)
                ->
where('entity_type_id = ?'$attribute->getEntityTypeId())
                ->
where('attribute_id = ?'$attribute->getAttributeId())
                ->
where('store_id = ?'$this->getDefaultStoreId())
                ->
where('entity_id = ?',  $object->getEntityId());
            
$row $this->_getReadAdapter()->fetchOne($select);
                
            if (!
$row{
            
// update only if default value not present
            // end bugfix
              
$bind = array(
                  
'entity_type_id'    => $attribute->getEntityTypeId(),
                  
'attribute_id'      => $attribute->getAttributeId(),
                  
'store_id'          => $this->getDefaultStoreId(),
                  
'entity_id'         => $object->getEntityId(),
                  
'value'             => $this->_prepareValueForSave($value$attribute)
              );
              
$this->_getWriteAdapter()->insertOnDuplicate($table$bind, array('value'));
            
// bugfix for updating default values from 1.6
            
}
            
// end bugfix
        
}
        
return $this->_saveAttributeValue($object$attribute$value);
    
}

In attachment there is the bug-fixed abstract, just copy it in to “app/code/local/Mage/Catalog/Model/Resource/Eav/Mysql4/”, or if you already made some changes, just replace the bugged function.

File Attachments
Abstract.php  (File Size: 27KB - Downloads: 66)
 
Magento Community Magento Community
Magento Community
Magento Community
 
designer84
Sr. Member
 
Total Posts:  102
Joined:  2009-08-20
 
jEzEk CHiCKi - 15 February 2012 06:41 AM

So, the problem is in “app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Abstract.php” in function _insertAttribute($object, $attribute, $value), row 255. There is a condition: if attribute is required and store is not default store, so insert attribute for default store. This rewrites default values.



In attachment there is the bug-fixed abstract, just copy it in to “app/code/local/Mage/Catalog/Model/Resource/Eav/Mysql4/”, or if you already made some changes, just replace the bugged function.

We are giving this a try to see if it works on Pro v. 1.10.1.0 (same core as CE v. 1.5.1.0)

 
Magento Community Magento Community
Magento Community
Magento Community
 
amirshakya
Jr. Member
 
Total Posts:  5
Joined:  2011-02-03
 

Thanks for the solution I am facing the same problem..
Cheers…

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