firegento / firegento-dynamiccategory

Dynamically add products to a category based on an attribute selection.
GNU General Public License v3.0
87 stars 29 forks source link

Missing attribute name when attribute is sortable (Backend) #61

Open phizab opened 8 years ago

phizab commented 8 years ago

If I choose a condition by a product attribute, which is part of the sortable attributes under "Display Settings" > "Available Product Listing Sort by", I do not see the attribute's name after I saved the category (e.g. the attribute "name" in default Magento installation).

This is caused by the core method Mage_Catalog_Model_Config::getAttributesUsedForSortBy(), because the sortable attributes will not loaded completely and are missing fields like "is_visible". Nevertheless they will be cached in Mage_Eav_Model_Config and the rule conditions use this singleton with the incomplete data.

I've added the following line at the beginning of method FireGento_DynamicCategory_Model_Rule::loadPost(), but I know that this method is deprecated so please use this at your own risk. A better solution is needed here!

/**
 * Initialize the rule model data from the given array.
 *
 * @param  array $rule Rule data
 * @return FireGento_DynamicCategory_Model_Rule Self.
 */
public function loadPost(array $rule)
{
    // reset attributes cache to get all attributes loaded completely
    Mage::getSingleton('eav/config')->clear();

    $arr = $this->_convertFlatToRecursive($rule);

    [..]

    return $this;
}