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


PHP Mage_Eav_Model_Entity_Attribute::getId方法代码示例

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


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

示例1: saveAttribute

 private function saveAttribute()
 {
     if ($this->attributeObj->getId()) {
         return array('result' => true, 'obj' => $this->attributeObj);
     }
     if (!$this->validate()) {
         return array('result' => false, 'error' => 'Attribute builder. Validation failed.');
     }
     $this->attributeObj = Mage::getModel('catalog/resource_eav_attribute');
     $data = $this->params;
     $data['attribute_code'] = $this->code;
     $data['frontend_label'] = array(Mage_Core_Model_App::ADMIN_STORE_ID => $this->primaryLabel);
     $data['frontend_input'] = $this->inputType;
     $data['entity_type_id'] = $this->entityTypeId;
     $data['is_user_defined'] = 1;
     $data['source_model'] = Mage::helper('catalog/product')->getAttributeSourceModelByInputType($this->inputType);
     $data['backend_model'] = Mage::helper('catalog/product')->getAttributeBackendModelByInputType($this->inputType);
     $data['backend_type'] = $this->attributeObj->getBackendTypeByInput($this->inputType);
     !isset($data['is_global']) && ($data['is_global'] = self::SCOPE_STORE);
     !isset($data['is_configurable']) && ($data['is_configurable'] = 0);
     !isset($data['is_filterable']) && ($data['is_filterable'] = 0);
     !isset($data['is_filterable_in_search']) && ($data['is_filterable_in_search'] = 0);
     !isset($data['apply_to']) && ($data['apply_to'] = array());
     $this->prepareOptions($data);
     $this->prepareDefault($data);
     $this->attributeObj->addData($data);
     try {
         $this->attributeObj->save();
     } catch (Exception $e) {
         return array('result' => false, 'error' => $e->getMessage());
     }
     return array('result' => true, 'obj' => $this->attributeObj);
 }
开发者ID:Vitafy,项目名称:M2E,代码行数:33,代码来源:Builder.php

示例2: copyAttributeValues

 /**
  * Copy all eav attribute values for a specified attribute from one table to another eav attribute table,
  * updating the attribute id. The old records remain in the old value table.
  *
  * @param Mage_Eav_Model_Entity_Attribute $oldAttribute
  * @param Mage_Eav_Model_Entity_Attribute $newAttribute
  * @return array Affected entity ids
  */
 public function copyAttributeValues(Mage_Eav_Model_Entity_Attribute $oldAttribute, Mage_Eav_Model_Entity_Attribute $newAttribute)
 {
     $select = $this->_getReadAdapter()->select()->reset()->distinct(true)->from($oldAttribute->getBackendTable(), 'entity_id')->where('attribute_id=:attribute_id');
     $entityIds = $this->_getReadAdapter()->fetchCol($select, array('attribute_id' => $oldAttribute->getId()));
     // Remove new attribute value records for entities that are being migrated
     $this->_getWriteAdapter()->delete($newAttribute->getBackendTable(), array('attribute_id=?' => $newAttribute->getId(), 'entity_id IN(?)' => $entityIds));
     // Copy old attribute values to the new attribute
     $selectFields = array('entity_type_id', new Zend_Db_Expr($newAttribute->getId()), 'store_id', 'entity_id', 'value');
     $insertFields = array('entity_type_id', 'attribute_id', 'store_id', 'entity_id', 'value');
     $select->reset()->from($oldAttribute->getBackendTable(), $selectFields)->where('attribute_id=?', $oldAttribute->getId());
     $update = $this->_getWriteAdapter()->insertFromSelect($select, $newAttribute->getBackendTable(), $insertFields, Varien_Db_Adapter_Interface::INSERT_IGNORE);
     $this->_getWriteAdapter()->query($update);
     return $entityIds;
 }
开发者ID:aniljaiswal,项目名称:order-confirmation,代码行数:22,代码来源:Migration.php

示例3: saveAttribute

 private function saveAttribute()
 {
     if ($this->attributeObj->getId()) {
         return array('result' => true, 'obj' => $this->attributeObj, 'code' => $this->attributeObj->getAttributeCode());
     }
     if (!$this->validate()) {
         return array('result' => false, 'error' => 'Attribute builder. Validation failed.');
     }
     $data = $this->params;
     $data['attribute_code'] = $this->code;
     $data['frontend_label'] = array(Mage_Core_Model_App::ADMIN_STORE_ID => $this->primaryLabel);
     $data['frontend_input'] = $this->inputType;
     $data['source_model'] = Mage::helper('catalog/product')->getAttributeSourceModelByInputType($this->inputType);
     $data['backend_model'] = Mage::helper('catalog/product')->getAttributeBackendModelByInputType($this->inputType);
     !isset($data['is_global']) && ($data['is_global'] = self::SCOPE_STORE);
     !isset($data['is_configurable']) && ($data['is_configurable'] = 0);
     !isset($data['is_filterable']) && ($data['is_filterable'] = 0);
     !isset($data['is_filterable_in_search']) && ($data['is_filterable_in_search'] = 0);
     $this->attributeObj = Mage::getModel('catalog/resource_eav_attribute');
     if (is_null($this->attributeObj->getIsUserDefined()) || $this->attributeObj->getIsUserDefined() != 0) {
         $data['backend_type'] = $this->attributeObj->getBackendTypeByInput($this->inputType);
     }
     // default value
     if (empty($data['default_value'])) {
         unset($data['default_value']);
     }
     // ---------------------------------------
     !isset($data['apply_to']) && ($data['apply_to'] = array());
     // prepare options
     foreach ($this->options as $optionValue) {
         $code = 'option_' . substr(sha1($optionValue), 0, 6);
         $data['option']['value'][$code] = array(Mage_Core_Model_App::ADMIN_STORE_ID => $optionValue);
     }
     // ---------------------------------------
     $this->attributeObj->addData($data);
     $this->attributeObj->setEntityTypeId($this->entityTypeId);
     $this->attributeObj->setIsUserDefined(1);
     try {
         $this->attributeObj->save();
     } catch (Exception $e) {
         return array('result' => false, 'error' => $e->getMessage());
     }
     return array('result' => true, 'obj' => $this->attributeObj, 'code' => $this->attributeObj->getAttributeCode());
 }
开发者ID:aligent,项目名称:M2E,代码行数:44,代码来源:Builder.php

示例4: getOptions

 /**
  * Gets attribute options from database
  *
  * @param \Mage_Eav_Model_Entity_Attribute $attribute
  *
  * @return array
  */
 protected function getOptions($attribute)
 {
     $select = $this->readConnection->select()->from(array('o' => \Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')))->join(array('ov' => \Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')), 'o.option_id = ov.option_id')->where('o.attribute_id = ?', $attribute->getId())->where('ov.store_id = 0')->order('ov.option_id');
     $query = $select->query();
     $values = array();
     foreach ($query->fetchAll() as $row) {
         $values[] = $row['value'];
     }
     return array('values' => $values);
 }
开发者ID:navarr,项目名称:n98-magerun,代码行数:17,代码来源:AbstractEntityType.php

示例5: deleteProductData

 /**
  * Delete product data
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_Eav_Model_Entity_Attribute $attribute
  * @return Enterprise_GiftCard_Model_Resource_Attribute_Backend_Giftcard_Amount
  */
 public function deleteProductData($product, $attribute)
 {
     $condition = array();
     if (!$attribute->isScopeGlobal()) {
         if ($storeId = $product->getStoreId()) {
             $condition['website_id IN (?)'] = array(0, Mage::app()->getStore($storeId)->getWebsiteId());
         }
     }
     $condition['entity_id=?'] = $product->getId();
     $condition['attribute_id=?'] = $attribute->getId();
     $this->_getWriteAdapter()->delete($this->getMainTable(), $condition);
     return $this;
 }
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:20,代码来源:Amount.php

示例6: 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);
 }
开发者ID:nemphys,项目名称:magento2,代码行数:14,代码来源:Category.php

示例7: _assignAttributeToAttributeSet

 /**
  * Assigns the attribute to the attribute set
  *
  * @param Mage_Eav_Model_Entity_Attribute $attribute
  * @param Mage_Eav_Model_Entity_Attribute_Set $attributeSet
  * @param int $attributeGroupId
  */
 protected function _assignAttributeToAttributeSet($attribute, $attributeSet, $attributeGroupId)
 {
     $entityTypeId = $this->_getEntityTypeId();
     $setup = Mage::getModel('eav/entity_setup', 'core_setup');
     $setup->addAttributeToSet($entityTypeId, $attributeSet->getId(), $attributeGroupId, $attribute->getId());
 }
开发者ID:mblarsen,项目名称:magento-configurator,代码行数:13,代码来源:AttributeSets.php

示例8: isAttributeInAttributeSet

 private function isAttributeInAttributeSet(Mage_Eav_Model_Entity_Attribute $attribute, $attributeSetId)
 {
     $attributesMatchingInNewAttributeSet = $attribute->getResourceCollection()->setAttributeSetFilter($attributeSetId)->addFieldToFilter('entity_attribute.attribute_id', $attribute->getId())->load();
     return count($attributesMatchingInNewAttributeSet) === 0;
 }
开发者ID:robbieaverill,项目名称:Magento-ChangeAttributeSet,代码行数:5,代码来源:ProductController.php

示例9: _getAttributeValueInfo

 /**
  * Returns attribute meta info for record,
  * e.g. entity_type_id, attribute_id, etc
  *
  * @param array $row
  * @param Mage_Eav_Model_Entity_Attribute $attribute
  * @return array
  */
 protected function _getAttributeValueInfo($row, $attribute)
 {
     return array('attribute_id' => $attribute->getId(), 'entity_type_id' => $attribute->getEntityTypeId(), $this->_getEntityIdField($attribute) => $row[$this->_getEntityIdField($attribute)]);
 }
开发者ID:cmuench,项目名称:EcomDev_PHPUnit,代码行数:12,代码来源:AbstractEav.php

示例10: checkIsAlreadyInSet

 private function checkIsAlreadyInSet()
 {
     /* @var $collection Mage_Eav_Model_Resource_Entity_Attribute_Collection */
     $collection = Mage::getModel('eav/entity_attribute')->getResourceCollection()->setAttributeSetFilter($this->setId)->addFieldToFilter('entity_attribute.attribute_id', $this->attributeObj->getId());
     return $collection->getSize() > 0;
 }
开发者ID:ReeceCrossland,项目名称:essua-m2epro,代码行数:6,代码来源:Relation.php

示例11: _migrateData

 /**
  * Migrate Entries from source to target tables (if possible)
  *
  * TODO: Delete existing Select/Multiselect Values if the new Backend Type is not one of Select/Multiselect
  *
  * @param Mage_Eav_Model_Entity_Attribute $attribute  Attribute Model
  * @param string                          $targetType Target Backend Type
  * @return void
  */
 protected function _migrateData($attribute, $targetType)
 {
     /** @var Varien_Db_Adapter_Interface $_dbConnection */
     $_dbConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
     // e.g. Entity is 'catalog_product'
     $entityTypeCode = $attribute->getEntity()->getData('entity_type_code');
     // Set Backend Types for later reference
     $sourceType = $attribute->getBackendType();
     // Create complete Entity Table names, e.g. 'catalog_product_entity_text'
     $sourceTable = implode([$entityTypeCode, 'entity', $sourceType], '_');
     $targetTable = implode([$entityTypeCode, 'entity', $targetType], '_');
     // Select all existing entries for given Attribute
     $srcSql = 'SELECT' . ' * FROM ' . $sourceTable . ' WHERE attribute_id = ? AND entity_type_id = ?';
     /** @var Zend_Db_Statement_Interface $sourceQuery */
     $sourceQuery = $_dbConnection->query($srcSql, [$attribute->getId(), $attribute->getEntity()->getData('entity_type_id')]);
     $this->_migrateNonSelect($targetType, $sourceQuery, $sourceType, $targetTable, $_dbConnection, $sourceTable);
 }
开发者ID:aoepeople,项目名称:aoe_attributeconfigurator,代码行数:26,代码来源:Attribute.php

示例12: getAttributeAdminLabel

 /**
  * Get Human Readable label for attribute value option
  *
  * @param Mage_Eav_Model_Entity_Attribute $attribute
  * @param int|string                      $attributeValueId
  *
  * @return string|boolean
  */
 public function getAttributeAdminLabel($attribute, $attributeValueId)
 {
     $_collection = Mage::getResourceModel('eav/entity_attribute_option_collection')->setStoreFilter(0)->setAttributeFilter($attribute->getId())->load();
     foreach ($_collection->toOptionArray() as $_cur_option) {
         if ($_cur_option['value'] == $attributeValueId) {
             return $_cur_option['label'];
         }
     }
     return false;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:18,代码来源:Data.php

示例13: getAttributeInSets

 /**
  * get the attribute set collection that an attribute belongs to
  * @param Mage_Eav_Model_Entity_Attribute $attribute
  * @return Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection
  */
 public function getAttributeInSets($attribute)
 {
     $collection = Mage::getResourceModel('eav/entity_attribute_set_collection')->addFieldToFilter('main_table.entity_type_id', $attribute->getEntityTypeId());
     $collection->getSelect()->join(array('entity_attribute' => $this->getTable('eav/entity_attribute')), 'main_table.attribute_set_id = entity_attribute.attribute_set_id', array('entity_attribute_id'))->where('entity_attribute.attribute_id = ?', $attribute->getId());
     return $collection;
 }
开发者ID:hanhpv,项目名称:bulk-assigning-attributes,代码行数:11,代码来源:Attribute.php


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