当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Eav_Model_Entity_Attribute_Abstract::getValues方法代码示例

本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute_Abstract::getValues方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute_Abstract::getValues方法的具体用法?PHP Mage_Eav_Model_Entity_Attribute_Abstract::getValues怎么用?PHP Mage_Eav_Model_Entity_Attribute_Abstract::getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Eav_Model_Entity_Attribute_Abstract的用法示例。


在下文中一共展示了Mage_Eav_Model_Entity_Attribute_Abstract::getValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: savePrices

 /**
  * Save Options prices (Depends from price save scope)
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Type_Configurable_Attribute
  */
 public function savePrices($attribute)
 {
     $newValues = $attribute->getValues();
     $oldValues = array();
     $valueIndexes = array();
     $select = $this->_getWriteAdapter()->select()->from($this->_priceTable)->where('product_super_attribute_id=?', $attribute->getId());
     $query = $this->_getWriteAdapter()->query($select);
     while ($row = $query->fetch()) {
         $key = join('-', array($row['website_id'], $row['value_index']));
         $oldValues[$key] = $row;
     }
     $delete = array();
     $insert = array();
     $update = array();
     foreach ($newValues as $value) {
         $valueIndexes[$value['value_index']] = $value['value_index'];
     }
     if ($this->getCatalogHelper()->isPriceGlobal()) {
         foreach ($oldValues as $row) {
             if (!isset($valueIndexes[$row['value_index']])) {
                 $delete[] = $row['value_id'];
                 continue;
             }
         }
         foreach ($newValues as $value) {
             $valueObject = new Varien_Object($value);
             $key = join('-', array(0, $value['value_index']));
             $pricingValue = $valueObject->getPricingValue();
             if ($pricingValue == '' || is_null($pricingValue)) {
                 $pricingValue = null;
             } else {
                 $pricingValue = Mage::app()->getLocale()->getNumber($pricingValue);
             }
             // update
             if (isset($oldValues[$key])) {
                 $oldValue = $oldValues[$key];
                 $update[$oldValue['value_id']] = array('pricing_value' => $pricingValue, 'is_percent' => intval($valueObject->getIsPercent()));
             } else {
                 if (!empty($value['pricing_value'])) {
                     $insert[] = array('product_super_attribute_id' => $attribute->getId(), 'value_index' => $valueObject->getValueIndex(), 'is_percent' => intval($valueObject->getIsPercent()), 'pricing_value' => $pricingValue, 'website_id' => 0);
                 }
             }
         }
     } else {
         $websiteId = Mage::app()->getStore($attribute->getStoreId())->getWebsiteId();
         foreach ($oldValues as $row) {
             if (!isset($valueIndexes[$row['value_index']])) {
                 $delete[] = $row['value_id'];
                 continue;
             }
         }
         foreach ($newValues as $value) {
             $valueObject = new Varien_Object($value);
             $key = join('-', array($websiteId, $value['value_index']));
             $pricingValue = $valueObject->getPricingValue();
             if ($pricingValue == '' || is_null($pricingValue)) {
                 $pricingValue = null;
             } else {
                 $pricingValue = Mage::app()->getLocale()->getNumber($pricingValue);
             }
             // update
             if (isset($oldValues[$key])) {
                 $oldValue = $oldValues[$key];
                 if ($websiteId && $valueObject->getUseDefaultValue()) {
                     $delete[] = $oldValue['value_id'];
                 } else {
                     $update[$oldValue['value_id']] = array('pricing_value' => $pricingValue, 'is_percent' => intval($valueObject->getIsPercent()));
                 }
             } else {
                 if ($websiteId && $valueObject->getUseDefaultValue()) {
                     continue;
                 }
                 $insert[] = array('product_super_attribute_id' => $attribute->getId(), 'value_index' => $valueObject->getValueIndex(), 'is_percent' => intval($valueObject->getIsPercent()), 'pricing_value' => $pricingValue, 'website_id' => $websiteId);
             }
             $key = join('-', array(0, $value['value_index']));
             if (!isset($oldValues[$key])) {
                 $insert[] = array('product_super_attribute_id' => $attribute->getId(), 'value_index' => $valueObject->getValueIndex(), 'is_percent' => 0, 'pricing_value' => null, 'website_id' => 0);
             }
         }
     }
     if (!empty($delete)) {
         $where = $this->_getWriteAdapter()->quoteInto('value_id IN(?)', $delete);
         $this->_getWriteAdapter()->delete($this->_priceTable, $where);
     }
     if (!empty($update)) {
         foreach ($update as $valueId => $valueData) {
             $where = $this->_getWriteAdapter()->quoteInto('value_id=?', $valueId);
             $this->_getWriteAdapter()->update($this->_priceTable, $valueData, $where);
         }
     }
     if (!empty($insert)) {
         foreach ($insert as $valueData) {
             $this->_getWriteAdapter()->insert($this->_priceTable, $valueData);
         }
//.........这里部分代码省略.........
开发者ID:jauderho,项目名称:magento-mirror,代码行数:101,代码来源:Attribute.php


注:本文中的Mage_Eav_Model_Entity_Attribute_Abstract::getValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。