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


PHP Mage_Eav_Model_Entity_Attribute::getFlatUpdateSelect方法代码示例

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


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

示例1: updateAttribute

 /**
  * Update attribute flat data
  *
  * @param Mage_Eav_Model_Entity_Attribute $attribute
  * @param int $storeId
  * @param int|array $productIds update only product(s)
  * @return Mage_Catalog_Model_Resource_Product_Flat_Indexer
  */
 public function updateAttribute($attribute, $storeId, $productIds = null)
 {
     if (!$this->_isFlatTableExists($storeId)) {
         return $this;
     }
     $adapter = $this->_getWriteAdapter();
     $flatTableName = $this->getFlatTableName($storeId);
     $describe = $adapter->describeTable($flatTableName);
     if ($attribute->getBackend()->getType() == 'static') {
         if (!isset($describe[$attribute->getAttributeCode()])) {
             return $this;
         }
         $select = $adapter->select()->join(array('main_table' => $this->getTable('catalog/product')), 'main_table.entity_id = e.entity_id', array($attribute->getAttributeCode() => 'main_table.' . $attribute->getAttributeCode()));
         if ($this->getFlatHelper()->isAddChildData()) {
             $select->where('e.is_child = ?', 0);
         }
         if ($productIds !== null) {
             $select->where('main_table.entity_id IN(?)', $productIds);
         }
         $sql = $select->crossUpdateFromSelect(array('e' => $flatTableName));
         $adapter->query($sql);
     } else {
         $columns = $attribute->getFlatColumns();
         if (!$columns) {
             return $this;
         }
         foreach (array_keys($columns) as $columnName) {
             if (!isset($describe[$columnName])) {
                 return $this;
             }
         }
         $select = $attribute->getFlatUpdateSelect($storeId);
         if ($select instanceof Varien_Db_Select) {
             if ($productIds !== null) {
                 $select->where('e.entity_id IN(?)', $productIds);
             }
             $sql = $select->crossUpdateFromSelect(array('e' => $flatTableName));
             $adapter->query($sql);
         }
     }
     return $this;
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:50,代码来源:Indexer.php

示例2: updateAttribute

 /**
  * Update attribute flat data
  *
  * @param Mage_Eav_Model_Entity_Attribute $attribute
  * @param int $store
  * @param int|array $productIds update only product(s)
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Flat_Indexer
  */
 public function updateAttribute($attribute, $store, $productIds = null)
 {
     if ($attribute->getBackend()->getType() == 'static') {
         $select = $this->_getWriteAdapter()->select()->join(array('main_table' => $this->getTable('catalog/product')), 'main_table.entity_id=e.entity_id ', array($attribute->getAttributeCode() => 'main_table.' . $attribute->getAttributeCode()));
         if ($this->getFlatHelper()->isAddChildData()) {
             $select->where("e.is_child=?", 0);
         }
         if (!is_null($productIds)) {
             $select->where('main_table.entity_id IN(?)', $productIds);
         }
         $sql = $select->crossUpdateFromSelect(array('e' => $this->getFlatTableName($store)));
         $this->_getWriteAdapter()->query($sql);
     } else {
         $select = $attribute->getFlatUpdateSelect($store);
         if ($select instanceof Varien_Db_Select) {
             if (!is_null($productIds)) {
                 $select->where('e.entity_id IN(?)', $productIds);
             }
             $sql = $select->crossUpdateFromSelect(array('e' => $this->getFlatTableName($store)));
             $this->_getWriteAdapter()->query($sql);
         }
     }
     return $this;
 }
开发者ID:jauderho,项目名称:magento-mirror,代码行数:32,代码来源:Indexer.php

示例3: _updateAttribute

 /**
  * add product eav Attribute to document
  *
  * @param int $storeId
  * @param Mage_Eav_Model_Entity_Attribute $attribute
  * @param array $documents
  * @return array
  */
 public function _updateAttribute($storeId, $attribute, $documents = null)
 {
     $fields = $this->getMappings($storeId);
     $adapter = $this->_getReadAdapter();
     if ($attribute->getBackend()->getType() == 'static') {
         var_dump('not implemented yet');
         return $this;
         if (false === isset($describe[$attribute->getAttributeCode()])) {
             return $this;
         }
         $select = $adapter->select()->join(array('main_table' => $this->getTable('catalog/product')), 'main_table.entity_id = e.entity_id', array($attribute->getAttributeCode() => 'main_table.' . $attribute->getAttributeCode()));
         $select->where('main_table.entity_id IN(?)', array_map('intval', array_keys($documents)));
         $sql = $select->crossUpdateFromSelect(array('e' => $flatTableName));
         var_dump($sql);
         die;
         $adapter->query($sql);
     } else {
         //non static attributes
         $columns = $attribute->getFlatColumns();
         if (!$columns) {
             return $this;
         }
         foreach (array_keys($columns) as $columnName) {
             if (false === isset($fields[$columnName])) {
                 return $this;
             }
         }
         $select = $attribute->getFlatUpdateSelect($storeId);
         $select->from(array('e' => $this->getTable('catalog/product')), 'entity_id');
         if ($select instanceof Varien_Db_Select) {
             $select->where('e.entity_id IN(?)', array_map('intval', array_keys($documents)));
             foreach ($adapter->query($select)->fetchAll() as $data) {
                 $documentId = $data['entity_id'];
                 //remove entity id Field
                 unset($data['entity_id']);
                 if (true === isset($documents[$documentId])) {
                     if (true === is_array($data) && count($data) > 0) {
                         foreach ($data as $field => $value) {
                             $documents[$documentId]->set($field, $value);
                         }
                     }
                 }
             }
         }
     }
     return $documents;
 }
开发者ID:Mohitsahu123,项目名称:Elasticgento,代码行数:55,代码来源:Elasticgento.php


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