Skip to content

Commit

Permalink
fix backend import functionality
Browse files Browse the repository at this point in the history
Because ApiImport prevents rewrites, we don't force an entity model
across the system. This is fine when doing manual programmatic imports
but the Mage_ImportExport admin controller does its own setup of these
models.

Since the bundle module requires access to a protected property and
the Mage_ImportExport_Model_Entity_Product class doesn't expose it
publicly, we have to fetch it using reflection instead.

Closes #30.
  • Loading branch information
danslo committed Mar 17, 2015
1 parent 4f6057a commit 151bba1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion code/Model/Import/Entity/Product/Type/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ public function _initAttributes()
return $this;
}

/**
* Use reflection to get stores because by default it is protected.
* We do this to prevent a rewrite on the ImportExport controller which forces
* a specific entity model.
*
* @return array
*/
protected function _getStores()
{
$obj = new ReflectionObject($this->_entityModel);
$prop = $obj->getProperty('_storeCodeToId');
$prop->setAccessible(true);
return $prop->getValue($this->_entityModel);
}

/**
* Saves data specific to bundle products.
*
Expand All @@ -110,7 +125,7 @@ public function saveData()
$connection = $this->_entityModel->getConnection();
$newSku = $this->_entityModel->getNewSku();
$oldSku = $this->_entityModel->getOldSku();
$stores = $this->_entityModel->getStores();
$stores = $this->_getStores();
$optionTable = Mage::getSingleton('core/resource')->getTableName('bundle/option');
$optionValueTable = Mage::getSingleton('core/resource')->getTableName('bundle/option_value');
$selectionTable = Mage::getSingleton('core/resource')->getTableName('bundle/selection');
Expand Down

0 comments on commit 151bba1

Please sign in to comment.