Esempio n. 1
0
 /**
  * Retrieve data to be insterted after processing attribute
  *
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param int $storeId
  * @return array
  */
 protected function getInsertValues($attribute, $storeId)
 {
     $collection = Mage::getResourceModel('eav/entity_attribute_option_collection')->setStoreFilter($storeId)->setPositionOrder('asc')->setAttributeFilter($attribute->getId())->load();
     $options = $collection->toOptionArray();
     $data = array();
     foreach ($options as $option) {
         // Generate url value
         $urlValue = $this->getHelper()->transliterate($option['label']);
         // Check if this url key is taken and add -{count}
         $count = 0;
         $origUrlValue = $urlValue;
         do {
             $found = false;
             foreach ($data as $line) {
                 if ($line['url_value'] == $urlValue) {
                     $found = true;
                 }
             }
             if ($found) {
                 $urlValue = $origUrlValue . '-' . ++$count;
             }
         } while ($found);
         $data[] = array('attribute_code' => $attribute->getAttributeCode(), 'attribute_id' => $attribute->getId(), 'store_id' => $storeId, 'option_id' => $option['value'], 'url_key' => $this->getHelper()->transliterate($attribute->getStoreLabel($storeId)), 'url_value' => $urlValue);
     }
     return $data;
 }