1

I'm building a 'global importer' module that allows an admin to upload a csv, choose a model and import.

Is there a way to check if the model is not an EAV entity (since flat csv's will not work with EAV entities)?

Here's the code being used to get a list of the Models:

public function getModels(){
    $models = array();
    $aliases = array();
    foreach (Mage::getConfig()->getNode('global/models') as $key=>$value) {
        $aliases[] = $value;
    }
    foreach($aliases[0] as $object){
        $models[] = $object->class;
    }
    return $models;
}

1 Answer 1

0

First Things First

There are three basic entity storage types in Magento. Flat, Complex, and EAV. What you are building can only work for entities with flat storage unless you get into code and DB introspection. Even with tremendous effort, it would be a never-ending pursuit to handle all of the possible ways of handling entities such as Magento's native CMS page and block.*

Second Things Second

Your config parsing code finds module model folders, not actual models. You need to discover individual class definitions based on these model folder paths. However, you can't stop at model definitions, because models do not know (or care) which entity storage pattern is used (and this is a Good Thing®). Rather, you need to discover each model's (instanceof Mage_CoreModel_Abstract to be clear) associated resource model in order to determine if it's a "flat" storage entity. (Of course, depending on configuration, even the Product and Category entities may "appear" to be flat.)

"Standard" flat entities in Magento 1.x in general are those with resource models which satisfy the following two conditions:

  • Subclass EITHER Mage_Core_Model_Resource_Db_Abstract OR Mage_Core_Model_Mysql4_Abstract (legacy)
  • DO NOT subclass Mage_Eav_Model_Entity_Abstract

Curious to see how this project goes. It's a great way to find a lot of yucky edges.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.