Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1480,4 +1480,43 @@ public function getOldCategory()
{
return $this->getCategoriesWithRoots();
}

/**
* Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param array $indexValAttrs OPTIONAL Additional attributes' codes with index values.
* @return array
*/
public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $indexValAttrs = array())
{
$options = array();

if ($attribute->usesSource()) {
// merge global entity index value attributes
$indexValAttrs = array_merge($indexValAttrs, $this->_indexValueAttributes);

// should attribute has index (option value) instead of a label?
$index = in_array($attribute->getAttributeCode(), $indexValAttrs) ? 'value' : 'label';

// only default (admin) store values used
$attribute->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);

try {
/** @var AvS_FastSimpleImport_Helper_Data $helper */
$helper = Mage::helper('fastsimpleimport');
foreach ($attribute->getSource()->getAllOptions(false) as $option) {
$value = is_array($option['value']) ? $option['value'] : array($option);
foreach ($value as $innerOption) {
if (strlen($innerOption['value'])) { // skip ' -- Please Select -- ' option
$options[$helper->strtolower($innerOption[$index])] = $innerOption['value'];
}
}
}
} catch (Exception $e) {
// ignore exceptions connected with source models
}
}
return $options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -703,4 +703,43 @@ public function getOldCustomers()
{
return $this->_oldCustomers;
}

/**
* Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param array $indexValAttrs OPTIONAL Additional attributes' codes with index values.
* @return array
*/
public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $indexValAttrs = array())
{
$options = array();

if ($attribute->usesSource()) {
// merge global entity index value attributes
$indexValAttrs = array_merge($indexValAttrs, $this->_indexValueAttributes);

// should attribute has index (option value) instead of a label?
$index = in_array($attribute->getAttributeCode(), $indexValAttrs) ? 'value' : 'label';

// only default (admin) store values used
$attribute->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);

try {
/** @var AvS_FastSimpleImport_Helper_Data $helper */
$helper = Mage::helper('fastsimpleimport');
foreach ($attribute->getSource()->getAllOptions(false) as $option) {
$value = is_array($option['value']) ? $option['value'] : array($option);
foreach ($value as $innerOption) {
if (strlen($innerOption['value'])) { // skip ' -- Please Select -- ' option
$options[$helper->strtolower($innerOption[$index])] = $innerOption['value'];
}
}
}
} catch (Exception $e) {
// ignore exceptions connected with source models
}
}
return $options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2210,4 +2210,43 @@ public function getEntityBySku($sku)
}
return false;
}

/**
* Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
* @param array $indexValAttrs OPTIONAL Additional attributes' codes with index values.
* @return array
*/
public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $indexValAttrs = array())
{
$options = array();

if ($attribute->usesSource()) {
// merge global entity index value attributes
$indexValAttrs = array_merge($indexValAttrs, $this->_indexValueAttributes);

// should attribute has index (option value) instead of a label?
$index = in_array($attribute->getAttributeCode(), $indexValAttrs) ? 'value' : 'label';

// only default (admin) store values used
$attribute->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);

try {
/** @var AvS_FastSimpleImport_Helper_Data $helper */
$helper = Mage::helper('fastsimpleimport');
foreach ($attribute->getSource()->getAllOptions(false) as $option) {
$value = is_array($option['value']) ? $option['value'] : array($option);
foreach ($value as $innerOption) {
if (strlen($innerOption['value'])) { // skip ' -- Please Select -- ' option
$options[$helper->strtolower($innerOption[$index])] = $innerOption['value'];
}
}
}
} catch (Exception $e) {
// ignore exceptions connected with source models
}
}
return $options;
}
}