cancel
Showing results for 
Search instead for 
Did you mean: 

Adding an additional website to product erases product's url key

Adding an additional website to product erases product's url key

If I edit a product and check one of the checkboxes for an additional website, the product's url key gets erased.

 

Before saving:

 

 

mysql> select * from catalog_product_entity_url_key where value LIKE 'test-product';                                                     +----------+----------------+--------------+----------+-----------+--------------+
| value_id | entity_type_id | attribute_id | store_id | entity_id | value        |
+----------+----------------+--------------+----------+-----------+--------------+
|  1672150 |              4 |           82 |        0 |    129583 | test-product |
+----------+----------------+--------------+----------+-----------+--------------+
1 row in set (0.05 sec)

 

 

After saving: 

 

mysql> select * from catalog_product_entity_url_key where value LIKE 'test-product';
Empty set (0.00 sec)

 

 

Magento ver. 1.14.2.0

 

I've disabled all local and community modules as well as renamed the local and community directories to be sure absolutely no 3rd party code is being executed and causing this.  All caching is disabled.

 

After enabling tracing for SQL queries I see that this delete query is being kicked off from the entity's save method.

 

 

## 2015-10-06 19:34:10
## 71216 ## QUERY
SQL: DELETE FROM `catalog_product_entity_url_key` WHERE (value_id IN (1672150))
AFF: 1
TIME: 0.0005
TRACE: #1 Magento_Db_Adapter_Pdo_Mysql[Varien_Db_Adapter_Pdo_Mysql]#000000004abca0f4000000017d77c9de#->_debugStat(2, 'DELETE FROM `cat...', array(), &Varien_Db_Statement_Pdo_Mysql#000000004abca3c5000000017d77c9de#) called at [lib/Varien/Db/Adapter/Pdo/Mysql.php:509]
#2 Magento_Db_Adapter_Pdo_Mysql[Varien_Db_Adapter_Pdo_Mysql]#000000004abca0f4000000017d77c9de#->query('DELETE FROM `cat...') called at [lib/Zend/Db/Adapter/Abstract.php:664]
#3 Magento_Db_Adapter_Pdo_Mysql[Zend_Db_Adapter_Abstract]#000000004abca0f4000000017d77c9de#->delete('catalog_product_...', array('value_id IN (?)' => array(1672150))) called at [app/code/core/Mage/Catalog/Model/Resource/Abstract.php:415]
#4 Mage_Catalog_Model_Resource_Product[Mage_Catalog_Model_Resource_Abstract]#000000004abca13a000000017d77c9de#->_deleteAttributes(&Mage_Catalog_Model_Product#000000004abca3fb000000017d77c9de#, 'catalog_product_...', array(array('attribute_id' => 82, 'value_id' => 1672150))) called at [app/code/core/Mage/Eav/Model/Entity/Abstract.php:1388]
#5 Mage_Catalog_Model_Resource_Product[Mage_Eav_Model_Entity_Abstract]#000000004abca13a000000017d77c9de#->_processSaveData(array('newObject' => &Mage_Catalog_Model_Product#000000004abca3fb000000017d77c9de#, 'entityRow' => array('entity_id' => 129583, 'entity_type_id' => 4, 'attribute_set_id' => 4, 'type_id' => 'simple', 'sku' => 'test', 'created_at' => '2015-10-05T21:40...', 'updated_at' => '2015-10-06 19:34...', 'has_options' => 0, 'required_options' => 0), 'insert' => array('test', NULL, 2, 4, NULL, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1.0000, NULL, 1.0000, 1.0000, NULL, NULL), 'update' => array(), 'delete' => array('catalog_product_...' => array(array('attribute_id' => 82, 'value_id' => 1672150))))) called at [app/code/core/Mage/Eav/Model/Entity/Abstract.php:1123]
#6 Mage_Catalog_Model_Resource_Product[Mage_Eav_Model_Entity_Abstract]#000000004abca13a000000017d77c9de#->save(&Mage_Catalog_Model_Product#000000004abca3fb000000017d77c9de#) called at [app/code/core/Mage/Core/Model/Abstract.php:318]
#7 Mage_Catalog_Model_Product[Mage_Core_Model_Abstract]#000000004abca3fb000000017d77c9de#->save() called at [app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php:782]
#8 Mage_Adminhtml_Catalog_ProductController#000000004abca04f000000017d77c9de#->_copyAttributesBetweenStores(array(1), &Mage_Catalog_Model_Product#000000004abca1e5000000017d77c9de#) called at [app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php:732]
#9 Mage_Adminhtml_Catalog_ProductController#000000004abca04f000000017d77c9de#->saveAction() called at [app/code/core/Mage/Core/Controller/Varien/Action.php:418]
#10 Mage_Adminhtml_Catalog_ProductController[Mage_Core_Controller_Varien_Action]#000000004abca04f000000017d77c9de#->dispatch('save') called at [app/code/core/Mage/Core/Controller/Varien/Router/Standard.php:254]
#11 Mage_Core_Controller_Varien_Router_Admin[Mage_Core_Controller_Varien_Router_Standard]#000000004abca0f1000000017d77c9de#->match(&Mage_Core_Controller_Request_Http#000000004abca0db000000017d77c9de#) called at [app/code/core/Mage/Core/Controller/Varien/Front.php:172]
#12 Mage_Core_Controller_Varien_Front#000000004abca058000000017d77c9de#->dispatch() called at [app/code/core/Mage/Core/Model/App.php:354]
#13 Mage_Core_Model_App#000000004abca09d000000017d77c9de#->run(array('scope_code' => '', 'scope_type' => 'store', 'options' => array())) called at [app/Mage.php:684]
#14 Mage::run('', 'store') called at [index.php:102]

 

 

The event 'product_duplicate_attributes' is being dispatched from _copyAttributesBetweenStores in Mage_Adminhtml_Catalog_ProductController and handled by removeUrlKey in Enterprise_Catalog_Model_Observer which erases the url.  If the url_key attribute is set to global scope why is this function completely removing the product's url key.  If I comment out the removal of the url key I get an error when trying to save the product Product with the 'test-product' url_key attribute already exists.

 

I can't be the only one experiencing this.