本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute类的具体用法?PHP Mage_Eav_Model_Entity_Attribute怎么用?PHP Mage_Eav_Model_Entity_Attribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Eav_Model_Entity_Attribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _getAttributeRecords
/**
* Changed to support price attribute type multi-scope
* (non-PHPdoc)
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @see Mage_Test_Model_Mysql4_Fixture_Eav_Catalog_Abstract::_getAttributeRecords()
*/
protected function _getAttributeRecords($row, $attribute, $tableColumns)
{
if ($attribute->getFrontendInput() == 'price') {
$attribute->setIsGlobal(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE);
}
return parent::_getAttributeRecords($row, $attribute, $tableColumns);
}
开发者ID:NatashaOlut,项目名称:Mage_Test,代码行数:13,代码来源:Product.php
示例2: addOptionValueToCollection
/**
* Add Join with option value for collection select
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param Zend_Db_Expr $valueExpr
*
* @return Mage_Eav_Model_Mysql4_Entity_Attribute_Option
*/
public function addOptionValueToCollection($collection, $attribute, $valueExpr)
{
$attributeCode = $attribute->getAttributeCode();
$optionTable1 = $attributeCode . '_option_value_t1';
$optionTable2 = $attributeCode . '_option_value_t2';
$collection->getSelect()->joinLeft(array($optionTable1 => $this->getTable('eav/attribute_option_value')), "`{$optionTable1}`.`option_id`={$valueExpr}" . " AND `{$optionTable1}`.`store_id`='0'", array())->joinLeft(array($optionTable2 => $this->getTable('eav/attribute_option_value')), "`{$optionTable2}`.`option_id`={$valueExpr}" . " AND `{$optionTable1}`.`store_id`='{$collection->getStoreId()}'", array($attributeCode => "IFNULL(`{$optionTable2}`.`value`, `{$optionTable1}`.`value`)"));
return $this;
}
开发者ID:jauderho,项目名称:magento-mirror,代码行数:17,代码来源:Option.php
示例3: getAttributeFieldName
/**
* Retrieve attribute field name
*
*
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @return string
*/
public function getAttributeFieldName($attribute)
{
$name = $attribute->getAttributeCode();
if ($suffix = $this->getForm()->getFieldNameSuffix()) {
$name = $this->getForm()->addSuffixToName($name, $suffix);
}
return $name;
}
开发者ID:xiaoguizhidao,项目名称:bb,代码行数:15,代码来源:Gallery.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: addOptionValueToCollection
/**
* Add Join with option value for collection select
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param Zend_Db_Expr $valueExpr
* @return Mage_Eav_Model_Resource_Entity_Attribute_Option
*/
public function addOptionValueToCollection($collection, $attribute, $valueExpr)
{
$adapter = $this->_getReadAdapter();
$attributeCode = $attribute->getAttributeCode();
$optionTable1 = $attributeCode . '_option_value_t1';
$optionTable2 = $attributeCode . '_option_value_t2';
$tableJoinCond1 = "{$optionTable1}.option_id={$valueExpr} AND {$optionTable1}.store_id=0";
$tableJoinCond2 = $adapter->quoteInto("{$optionTable2}.option_id={$valueExpr} AND {$optionTable2}.store_id=?", $collection->getStoreId());
$valueExpr = $adapter->getCheckSql("{$optionTable2}.value_id IS NULL", "{$optionTable1}.value", "{$optionTable2}.value");
$collection->getSelect()->joinLeft(array($optionTable1 => $this->getTable('eav/attribute_option_value')), $tableJoinCond1, array())->joinLeft(array($optionTable2 => $this->getTable('eav/attribute_option_value')), $tableJoinCond2, array($attributeCode => $valueExpr));
return $this;
}
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:20,代码来源:Option.php
示例6: addOptionValueToCollection
/**
* Add Join with option value for collection select
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param Zend_Db_Expr $valueExpr
*
* @return Mage_Eav_Model_Mysql4_Entity_Attribute_Option
*/
public function addOptionValueToCollection($collection, $attribute, $valueExpr)
{
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
$attributeCode = $attribute->getAttributeCode();
$optionTable1 = $attributeCode . '_option_value_t1';
$optionTable2 = $attributeCode . '_option_value_t2';
$collection->getSelect()->joinLeft(array($optionTable1 => $this->getTable('eav/attribute_option_value')), "`{$optionTable1}`.`option_id`={$valueExpr}" . " AND `{$optionTable1}`.`store_id`='{$adminStore}'", $collection->getStoreId() != $adminStore ? array() : array($attributeCode . '_value' => "{$optionTable1}.value"));
if ($collection->getStoreId() != $adminStore) {
$collection->getSelect()->joinLeft(array($optionTable2 => $this->getTable('eav/attribute_option_value')), "`{$optionTable2}`.`option_id`={$valueExpr}" . " AND `{$optionTable1}`.`store_id`='{$collection->getStoreId()}'", array($attributeCode . '_value' => "IFNULL(`{$optionTable2}`.`value`, `{$optionTable1}`.`value`)"));
}
return $this;
}
开发者ID:jpbender,项目名称:mage_virtual,代码行数:21,代码来源:Option.php
示例7: 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
示例8: 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
示例9: setAttributeModel
/**
* Set attribute model to filter
*
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @return Mage_Catalog_Model_Layer_Filter_Abstract
*/
public function setAttributeModel($attribute)
{
$this->setRequestVar($attribute->getAttributeCode());
$this->setData('attribute_model', $attribute);
return $this;
}
开发者ID:jpbender,项目名称:mage_virtual,代码行数:12,代码来源:Abstract.php
示例10: getAttributeType
/**
* Get attribute type for upcoming validation.
*
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @return string
*/
public static function getAttributeType(Mage_Eav_Model_Entity_Attribute $attribute)
{
if ($attribute->usesSource()) {
return $attribute->getFrontendInput() == 'multiselect' ? 'multiselect' : 'select';
} elseif ($attribute->isStatic()) {
return $attribute->getFrontendInput() == 'date' ? 'datetime' : 'varchar';
} else {
return $attribute->getBackendType();
}
}
开发者ID:,项目名称:,代码行数:16,代码来源:
示例11: getAttributeFilterType
/**
* Determine filter type for specified attribute.
*
* @static
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @throws Exception
* @return string
*/
public static function getAttributeFilterType(Mage_Eav_Model_Entity_Attribute $attribute)
{
if ($attribute->usesSource() || $attribute->getFilterOptions()) {
return self::FILTER_TYPE_SELECT;
} elseif ('datetime' == $attribute->getBackendType()) {
return self::FILTER_TYPE_DATE;
} elseif ('decimal' == $attribute->getBackendType() || 'int' == $attribute->getBackendType()) {
return self::FILTER_TYPE_NUMBER;
} elseif ($attribute->isStatic() || 'varchar' == $attribute->getBackendType() || 'text' == $attribute->getBackendType()) {
return self::FILTER_TYPE_INPUT;
} else {
Mage::throwException(Mage::helper('importexport')->__('Can not determine attribute filter type'));
}
}
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:22,代码来源:Export.php
示例12: _updateDefaultValue
/**
* Update attribute default value
*
* @param Mage_Eav_Model_Entity_Attribute|Mage_Core_Model_Abstract $object
* @param int|string $optionId
* @param int $intOptionId
* @param array $defaultValue
*/
protected function _updateDefaultValue($object, $optionId, $intOptionId, &$defaultValue)
{
if (in_array($optionId, $object->getDefault())) {
$frontendInput = $object->getFrontendInput();
if ($frontendInput === 'multiselect') {
$defaultValue[] = $intOptionId;
} elseif ($frontendInput === 'select') {
$defaultValue = array($intOptionId);
}
}
}
开发者ID:natxetee,项目名称:magento2,代码行数:19,代码来源:Attribute.php
示例13: attributesCompare
/**
* Compare attributes
*
* @param Mage_Eav_Model_Entity_Attribute $attribute1
* @param Mage_Eav_Model_Entity_Attribute $attribute2
* @return int
*/
public function attributesCompare($attribute1, $attribute2)
{
$sortPath = sprintf('attribute_set_info/%s/sort', $this->_sortingSetId);
$groupSortPath = sprintf('attribute_set_info/%s/group_sort', $this->_sortingSetId);
$sort1 = $attribute1->getData($groupSortPath) * 1000 + $attribute1->getData($sortPath) * 0.0001;
$sort2 = $attribute2->getData($groupSortPath) * 1000 + $attribute2->getData($sortPath) * 0.0001;
if ($sort1 > $sort2) {
return 1;
} elseif ($sort1 < $sort2) {
return -1;
}
return 0;
}
开发者ID:test3metizsoft,项目名称:test,代码行数:20,代码来源:Abstract.php
示例14: canUseAttribute
/**
* Checkin attribute availability for create superproduct
*
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @return bool
*/
public function canUseAttribute(Mage_Eav_Model_Entity_Attribute $attribute)
{
$allow = $attribute->getIsGlobal() == Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL && $attribute->getIsVisible() && $attribute->getIsConfigurable() && $attribute->usesSource() && $attribute->getIsUserDefined();
return $allow;
}
开发者ID:njaeger,项目名称:magento_github,代码行数:11,代码来源:Configurable.php
示例15: 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
示例16: isReservedAttribute
/**
* Check whether attribute reserved or not
*
* @param Mage_Eav_Model_Entity_Attribute $attribute Attribute model object
* @return boolean
*/
public function isReservedAttribute($attribute)
{
return $attribute->getIsUserDefined() && in_array($attribute->getAttributeCode(), $this->getReservedAttributes());
}
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:10,代码来源:Product.php
示例17: 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
示例18: _addSearchCriteria
/**
* Add data about search criteria to object state
*
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param mixed $value
* @return Mage_CatalogSearch_Model_Advanced
*/
protected function _addSearchCriteria($attribute, $value)
{
$name = $attribute->getStoreLabel();
if (is_array($value)) {
if (isset($value['from']) && isset($value['to'])) {
if (!empty($value['from']) || !empty($value['to'])) {
if (isset($value['currency'])) {
$currencyModel = Mage::getModel('directory/currency')->load($value['currency']);
$from = $currencyModel->format($value['from'], array(), false);
$to = $currencyModel->format($value['to'], array(), false);
} else {
$currencyModel = null;
}
if (strlen($value['from']) > 0 && strlen($value['to']) > 0) {
// -
$value = sprintf('%s - %s', $currencyModel ? $from : $value['from'], $currencyModel ? $to : $value['to']);
} elseif (strlen($value['from']) > 0) {
// and more
$value = Mage::helper('catalogsearch')->__('%s and greater', $currencyModel ? $from : $value['from']);
} elseif (strlen($value['to']) > 0) {
// to
$value = Mage::helper('catalogsearch')->__('up to %s', $currencyModel ? $to : $value['to']);
}
} else {
return $this;
}
}
}
if (($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect') && is_array($value)) {
foreach ($value as $key => $val) {
$value[$key] = $attribute->getSource()->getOptionText($val);
if (is_array($value[$key])) {
$value[$key] = $value[$key]['label'];
}
}
$value = implode(', ', $value);
} else {
if ($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect') {
$value = $attribute->getSource()->getOptionText($value);
if (is_array($value)) {
$value = $value['label'];
}
} else {
if ($attribute->getFrontendInput() == 'boolean') {
$value = $value == 1 ? Mage::helper('catalogsearch')->__('Yes') : Mage::helper('catalogsearch')->__('No');
}
}
}
$this->_searchCriterias[] = array('name' => $name, 'value' => $value);
return $this;
}
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:58,代码来源:Advanced.php
示例19: 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
示例20: decorateFilter
/**
* Create filter fields for 'Filter' column.
*
* @param mixed $value
* @param Mage_Eav_Model_Entity_Attribute $row
* @param Varien_Object $column
* @param boolean $isExport
* @return string
*/
public function decorateFilter($value, Mage_Eav_Model_Entity_Attribute $row, Varien_Object $column, $isExport)
{
$value = null;
$values = $column->getValues();
if (is_array($values) && isset($values[$row->getAttributeCode()])) {
$value = $values[$row->getAttributeCode()];
}
switch (Mage_ImportExport_Model_Export::getAttributeFilterType($row)) {
case Mage_ImportExport_Model_Export::FILTER_TYPE_SELECT:
$cell = $this->_getSelectHtmlWithValue($row, $value);
break;
case Mage_ImportExport_Model_Export::FILTER_TYPE_INPUT:
$cell = $this->_getInputHtmlWithValue($row, $value);
break;
case Mage_ImportExport_Model_Export::FILTER_TYPE_DATE:
$cell = $this->_getDateFromToHtmlWithValue($row, $value);
break;
case Mage_ImportExport_Model_Export::FILTER_TYPE_NUMBER:
$cell = $this->_getNumberFromToHtmlWithValue($row, $value);
break;
default:
$cell = $this->_helper->__('Unknown attribute filter type');
}
return $cell;
}
开发者ID:hirentricore,项目名称:devmagento,代码行数:34,代码来源:Filter.php
注:本文中的Mage_Eav_Model_Entity_Attribute类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论