本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute::getBackend方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute::getBackend方法的具体用法?PHP Mage_Eav_Model_Entity_Attribute::getBackend怎么用?PHP Mage_Eav_Model_Entity_Attribute::getBackend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Attribute
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Attribute::getBackend方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findWhereAttributeIs
/**
* Return entities where attribute value is
*
* @param array|int $entityIdsFilter
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param mixed $expectedValue
* @return array
*/
public function findWhereAttributeIs($entityIdsFilter, $attribute, $expectedValue)
{
$bind = array('attribute_id' => $attribute->getId(), 'value' => $expectedValue);
$select = $this->_getReadAdapter()->select()->from($attribute->getBackend()->getTable(), array('entity_id'))->where('attribute_id = :attribute_id')->where('value = :value')->where('entity_id IN(?)', $entityIdsFilter);
return $this->_getReadAdapter()->fetchCol($select, $bind);
}
示例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;
}
示例3: _prepareEditableAttributeCommonConfig
/**
* Prepare common config values of given editable attribute
*
* @param string $type Grid block type
* @param string $code Attribute code
* @param Mage_Eav_Model_Entity_Attribute $attribute Attribute object
* @param array $config Field config
* @return array
*/
protected function _prepareEditableAttributeCommonConfig($type, $code, $attribute, $config)
{
if ($attribute->getBackend()->getType() == 'datetime') {
$config['render_reload'] = true;
$config['must_filter'] = true;
$config['filter_type'] = 'date';
}
return $config;
}
示例4: 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;
}
示例5: _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;
}