• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Attribute\AbstractAttribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Eav\Model\Entity\Attribute\AbstractAttribute的典型用法代码示例。如果您正苦于以下问题:PHP AbstractAttribute类的具体用法?PHP AbstractAttribute怎么用?PHP AbstractAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getScopeValue

 /**
  * @param ScopeInterface $scope
  * @param AbstractAttribute $attribute
  * @param bool $useDefault
  * @return string
  */
 protected function getScopeValue(ScopeInterface $scope, AbstractAttribute $attribute, $useDefault = false)
 {
     if ($attribute instanceof CatalogEavAttribute) {
         $useDefault = $useDefault || $attribute->isScopeGlobal();
     }
     return parent::getScopeValue($scope, $attribute, $useDefault);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:AttributePersistor.php


示例2: getMediaEntriesDataCollection

 /**
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @return array
  */
 protected function getMediaEntriesDataCollection(\Magento\Catalog\Model\Product $product, \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute)
 {
     $attributeCode = $attribute->getAttributeCode();
     $mediaData = $product->getData($attributeCode);
     if (!empty($mediaData['images']) && is_array($mediaData['images'])) {
         return $mediaData['images'];
     }
     return [];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:AbstractHandler.php


示例3: deleteProductData

 /**
  * Delete product data
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @return $this
  */
 public function deleteProductData($product, $attribute)
 {
     $where = array('entity_id = ?' => (int) $product->getId(), 'attribute_id = ?' => (int) $attribute->getId());
     $adapter = $this->_getWriteAdapter();
     if (!$attribute->isScopeGlobal()) {
         $storeId = $product->getStoreId();
         if ($storeId) {
             $where['website_id IN(?)'] = array(0, $this->_storeManager->getStore($storeId)->getWebsiteId());
         }
     }
     $adapter->delete($this->getMainTable(), $where);
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:20,代码来源:Tax.php


示例4: deleteProductData

 /**
  * Delete product data
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @return $this
  */
 public function deleteProductData($product, $attribute)
 {
     $where = ['entity_id = ?' => (int) $product->getId(), 'attribute_id = ?' => (int) $attribute->getId()];
     $connection = $this->getConnection();
     if (!$attribute->isScopeGlobal()) {
         $storeId = $product->getStoreId();
         if ($storeId) {
             $where['website_id IN(?)'] = [0, $this->_storeManager->getStore($storeId)->getWebsiteId()];
         }
     }
     $connection->delete($this->getMainTable(), $where);
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:20,代码来源:Tax.php


示例5: _saveAttributeValue

 /**
  * Insert or Update attribute data
  *
  * @param \Magento\Catalog\Model\AbstractModel $object
  * @param AbstractAttribute $attribute
  * @param mixed $value
  * @return $this
  */
 protected function _saveAttributeValue($object, $attribute, $value)
 {
     $connection = $this->getConnection();
     $storeId = (int) $this->_storeManager->getStore($object->getStoreId())->getId();
     $table = $attribute->getBackend()->getTable();
     $entityId = $this->resolveEntityId($object->getId(), $table);
     /**
      * If we work in single store mode all values should be saved just
      * for default store id
      * In this case we clear all not default values
      */
     if ($this->_storeManager->hasSingleStore()) {
         $storeId = $this->getDefaultStoreId();
         $connection->delete($table, ['attribute_id = ?' => $attribute->getAttributeId(), $this->getLinkField() . ' = ?' => $entityId, 'store_id <> ?' => $storeId]);
     }
     $data = new \Magento\Framework\DataObject(['attribute_id' => $attribute->getAttributeId(), 'store_id' => $storeId, $this->getLinkField() => $entityId, 'value' => $this->_prepareValueForSave($value, $attribute)]);
     $bind = $this->_prepareDataForTable($data, $table);
     if ($attribute->isScopeStore()) {
         /**
          * Update attribute value for store
          */
         $this->_attributeValuesToSave[$table][] = $bind;
     } elseif ($attribute->isScopeWebsite() && $storeId != $this->getDefaultStoreId()) {
         /**
          * Update attribute value for website
          */
         $storeIds = $this->_storeManager->getStore($storeId)->getWebsite()->getStoreIds(true);
         foreach ($storeIds as $storeId) {
             $bind['store_id'] = (int) $storeId;
             $this->_attributeValuesToSave[$table][] = $bind;
         }
     } else {
         /**
          * Update global attribute value
          */
         $bind['store_id'] = $this->getDefaultStoreId();
         $this->_attributeValuesToSave[$table][] = $bind;
     }
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:48,代码来源:Action.php


示例6: build

 /**
  * Build validation rules
  *
  * @param AbstractAttribute $attribute
  * @param array $data
  * @return array
  */
 public function build(AbstractAttribute $attribute, array $data)
 {
     $validation = [];
     if (isset($data['required']) && $data['required'] == 1) {
         $validation = array_merge($validation, ['required-entry' => true]);
     }
     if ($attribute->getFrontendInput() === 'price') {
         $validation = array_merge($validation, ['validate-zero-or-greater' => true]);
     }
     if ($attribute->getValidateRules()) {
         $validation = array_merge($validation, $attribute->getValidateRules());
     }
     $rules = [];
     foreach ($validation as $type => $ruleName) {
         $rule = [$type => $ruleName];
         if ($type === 'input_validation') {
             $rule = isset($this->validationRules[$ruleName]) ? $this->validationRules[$ruleName] : [];
         }
         $rules = array_merge($rules, $rule);
     }
     return $rules;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:EavValidationRules.php


示例7: build

 /**
  * Build validation rules
  *
  * @param AbstractAttribute $attribute
  * @param array $data
  * @return array
  */
 public function build(AbstractAttribute $attribute, array $data)
 {
     $rules = [];
     if (isset($data['required']) && $data['required'] == 1) {
         $rules['required-entry'] = true;
     }
     $validation = $attribute->getValidateRules();
     if (!empty($validation)) {
         foreach ($validation as $type => $ruleName) {
             switch ($type) {
                 case 'input_validation':
                     if (isset($this->validationRul[$type][$ruleName])) {
                         $rules = array_merge($rules, $this->validationRul[$type][$ruleName]);
                     }
                     break;
                 case 'min_text_length':
                 case 'max_text_length':
                     $rules = array_merge($rules, [$type => $ruleName]);
                     break;
             }
         }
     }
     return $rules;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:31,代码来源:EavValidationRules.php


示例8: setUp

 /**
  * Set up test
  *
  * @return void
  */
 protected function setUp()
 {
     $this->resource = $this->getMock('Magento\\Framework\\App\\Resource', ['getConnection', 'getTableName'], [], '', false);
     $this->ruleCollectionFactory = $this->getMock('Magento\\CatalogRule\\Model\\Resource\\Rule\\CollectionFactory', ['create', 'addFieldToFilter'], [], '', false);
     $this->backend = $this->getMock('Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\AbstractBackend', [], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface');
     $this->db = $this->getMock('Zend_Db_Statement_Interface', [], [], '', false);
     $this->website = $this->getMock('Magento\\Store\\Model\\Website', [], [], '', false);
     $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface', [], [], '', false);
     $this->combine = $this->getMock('Magento\\Rule\\Model\\Condition\\Combine', [], [], '', false);
     $this->rules = $this->getMock('Magento\\CatalogRule\\Model\\Rule', [], [], '', false);
     $this->logger = $this->getMock('Psr\\Log\\LoggerInterface', [], [], '', false);
     $this->attribute = $this->getMock('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [], [], '', false);
     $this->priceCurrency = $this->getMock('Magento\\Framework\\Pricing\\PriceCurrencyInterface');
     $this->dateFormat = $this->getMock('Magento\\Framework\\Stdlib\\DateTime', [], [], '', false);
     $this->dateTime = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\DateTime', [], [], '', false);
     $this->eavConfig = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->product = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false);
     $this->productFactory = $this->getMock('Magento\\Catalog\\Model\\ProductFactory', ['create'], [], '', false);
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $this->connection->expects($this->any())->method('query')->will($this->returnValue($this->db));
     $this->select->expects($this->any())->method('distinct')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('order')->will($this->returnSelf());
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnArgument(0));
     $this->storeManager->expects($this->any())->method('getWebsites')->will($this->returnValue([$this->website]));
     $this->storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($this->website));
     $this->rules->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->rules->expects($this->any())->method('getWebsiteIds')->will($this->returnValue([1]));
     $this->rules->expects($this->any())->method('getConditions')->will($this->returnValue($this->combine));
     $this->rules->expects($this->any())->method('getCustomerGroupIds')->will($this->returnValue([1]));
     $this->ruleCollectionFactory->expects($this->any())->method('create')->will($this->returnSelf());
     $this->ruleCollectionFactory->expects($this->any())->method('addFieldToFilter')->will($this->returnValue([$this->rules]));
     $this->product->expects($this->any())->method('load')->will($this->returnSelf());
     $this->product->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->product->expects($this->any())->method('getWebsiteIds')->will($this->returnValue([1]));
     $this->combine->expects($this->any())->method('validate')->will($this->returnValue(true));
     $this->attribute->expects($this->any())->method('getBackend')->will($this->returnValue($this->backend));
     $this->eavConfig->expects($this->any())->method('getAttribute')->will($this->returnValue($this->attribute));
     $this->productFactory->expects($this->any())->method('create')->will($this->returnValue($this->product));
     $this->indexBuilder = new \Magento\CatalogRule\Model\Indexer\IndexBuilder($this->ruleCollectionFactory, $this->priceCurrency, $this->resource, $this->storeManager, $this->logger, $this->eavConfig, $this->dateFormat, $this->dateTime, $this->productFactory);
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:50,代码来源:IndexBuilderTest.php


示例9: getFlatUpdateSelect

 /**
  * Retrieve Select for update Flat data
  *
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @param int $store
  * @param bool $hasValueField flag which require option value
  * @return \Magento\Framework\DB\Select
  */
 public function getFlatUpdateSelect(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $store, $hasValueField = true)
 {
     $adapter = $this->_getReadAdapter();
     $attributeTable = $attribute->getBackend()->getTable();
     $attributeCode = $attribute->getAttributeCode();
     $joinConditionTemplate = "%s.entity_id = %s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
     $joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', \Magento\Store\Model\Store::DEFAULT_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= ' AND e.child_id = t1.entity_id';
     }
     $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
     /** @var $select \Magento\Framework\DB\Select */
     $select = $adapter->select()->joinLeft(['t1' => $attributeTable], $joinCondition, [])->joinLeft(['t2' => $attributeTable], sprintf($joinConditionTemplate, 't1', 't2', 't2', 't2', 't2', $store), [$attributeCode => $valueExpr]);
     if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
         $valueIdExpr = $adapter->getCheckSql('to2.value_id > 0', 'to2.value', 'to1.value');
         $select->joinLeft(['to1' => $this->getTable('eav_attribute_option_value')], "to1.option_id = {$valueExpr} AND to1.store_id = 0", [])->joinLeft(['to2' => $this->getTable('eav_attribute_option_value')], $adapter->quoteInto("to2.option_id = {$valueExpr} AND to2.store_id = ?", $store), [$attributeCode . '_value' => $valueIdExpr]);
     }
     if ($attribute->getFlatAddChildData()) {
         $select->where('e.is_child = 0');
     }
     return $select;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:30,代码来源:Option.php


示例10: setUp

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @return void
  */
 protected function setUp()
 {
     $this->zendDbMock = $this->getMockBuilder('Zend_Db_Statement_Interface')->getMock();
     $this->zendDbMock->expects($this->any())->method('fetchColumn')->willReturn([]);
     $this->selectMock = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->setMethods(['from', 'where', 'joinInner', 'joinLeft', 'having', 'useStraightJoin', 'insertFromSelect', '__toString'])->getMock();
     $this->selectMock->expects($this->any())->method('from')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('where')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('joinInner')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('joinLeft')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('having')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('useStraightJoin')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('insertFromSelect')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('__toString')->willReturn('string');
     $this->connectionMock = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->getMock();
     $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock);
     $this->connectionMock->expects($this->any())->method('query')->willReturn($this->zendDbMock);
     $this->resourceMock = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
     $this->resourceMock->expects($this->any())->method('getTableName')->will($this->returnCallback(function ($arg) {
         return $arg;
     }));
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Db\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceMock);
     $this->loggerMock = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
     $dateTime = $this->getMockBuilder('DateTime')->getMock();
     $this->timezoneMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface')->getMock();
     $this->timezoneMock->expects($this->any())->method('scopeDate')->willReturn($dateTime);
     $this->dateTimeMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime')->getMock();
     $this->flagMock = $this->getMockBuilder('Magento\\Reports\\Model\\Flag')->disableOriginalConstructor()->setMethods(['setReportFlagCode', 'unsetData', 'loadSelf', 'setFlagData', 'setLastUpdate', 'save'])->getMock();
     $this->flagFactoryMock = $this->getMockBuilder('Magento\\Reports\\Model\\FlagFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->flagFactoryMock->expects($this->any())->method('create')->willReturn($this->flagMock);
     $this->validatorMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime\\Timezone\\Validator')->disableOriginalConstructor()->getMock();
     $this->backendMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\AbstractBackend')->disableOriginalConstructor()->getMock();
     $this->attributeMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute')->disableOriginalConstructor()->getMock();
     $this->attributeMock->expects($this->any())->method('getBackend')->willReturn($this->backendMock);
     $this->productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Product')->disableOriginalConstructor()->getMock();
     $this->productMock->expects($this->any())->method('getAttribute')->willReturn($this->attributeMock);
     $this->helperMock = $this->getMockBuilder('Magento\\Reports\\Model\\Resource\\Helper')->disableOriginalConstructor()->getMock();
     $this->viewed = new Viewed($this->contextMock, $this->loggerMock, $this->timezoneMock, $this->flagFactoryMock, $this->dateTimeMock, $this->validatorMock, $this->productMock, $this->helperMock);
 }
开发者ID:nja78,项目名称:magento2,代码行数:44,代码来源:ViewedTest.php


示例11: getAttributeType

 /**
  * Get attribute type for upcoming validation.
  *
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\Magento\Eav\Model\Entity\Attribute $attribute
  * @return string
  */
 public static function getAttributeType(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute)
 {
     $frontendInput = $attribute->getFrontendInput();
     if ($attribute->usesSource() && in_array($frontendInput, ['select', 'multiselect', 'boolean'])) {
         return $frontendInput;
     } elseif ($attribute->isStatic()) {
         return $frontendInput == 'date' ? 'datetime' : 'varchar';
     } else {
         return $attribute->getBackendType();
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:Import.php


示例12: getAttributeOptions

 /**
  * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
  *
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @return array
  */
 public function getAttributeOptions(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute)
 {
     $options = [];
     if ($attribute->usesSource()) {
         // should attribute has index (option value) instead of a label?
         $index = in_array($attribute->getAttributeCode(), $this->_indexValueAttributes) ? 'value' : 'label';
         // only default (admin) store values used
         $attribute->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID);
         try {
             foreach ($attribute->getSource()->getAllOptions(false) as $option) {
                 foreach (is_array($option['value']) ? $option['value'] : [$option] as $innerOption) {
                     if (strlen($innerOption['value'])) {
                         // skip ' -- Please Select -- ' option
                         $options[$innerOption['value']] = $innerOption[$index];
                     }
                 }
             }
         } catch (\Exception $e) {
             // ignore exceptions connected with source models
         }
     }
     return $options;
 }
开发者ID:kid17,项目名称:magento2,代码行数:29,代码来源:AbstractEntity.php


示例13: _isAttributeValueEmpty

 /**
  * Check is attribute value empty
  *
  * @param AbstractAttribute $attribute
  * @param mixed $value
  * @return bool
  */
 protected function _isAttributeValueEmpty(AbstractAttribute $attribute, $value)
 {
     return $attribute->isValueEmpty($value);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:AbstractEntity.php


示例14: createMetadataAttribute

 /**
  * @param  AbstractAttribute $attribute
  * @return Data\Eav\AttributeMetadata
  */
 private function createMetadataAttribute($attribute)
 {
     $data = $this->booleanPrefixMapper($attribute->getData());
     // fill options and validate rules
     $data[AttributeMetadata::OPTIONS] = $attribute->usesSource() ? $attribute->getSource()->getAllOptions() : array();
     $data[AttributeMetadata::VALIDATION_RULES] = $attribute->getValidateRules();
     // fill scope
     $data[AttributeMetadata::SCOPE] = $attribute->isScopeGlobal() ? 'global' : ($attribute->isScopeWebsite() ? 'website' : 'store');
     $data[AttributeMetadata::FRONTEND_LABEL] = [];
     $data[AttributeMetadata::FRONTEND_LABEL][0] = array(FrontendLabel::STORE_ID => 0, FrontendLabel::LABEL => $attribute->getFrontendLabel());
     if (is_array($attribute->getStoreLabels())) {
         foreach ($attribute->getStoreLabels() as $storeId => $label) {
             $data[AttributeMetadata::FRONTEND_LABEL][$storeId] = array(FrontendLabel::STORE_ID => $storeId, FrontendLabel::LABEL => $label);
         }
     }
     return $this->attributeMetadataBuilder->populateWithArray($data)->create();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:21,代码来源:MetadataService.php


示例15: _prepareOptionValues

 /**
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @param array|\Magento\Eav\Model\Resource\Entity\Attribute\Option\Collection $optionCollection
  * @return array
  */
 protected function _prepareOptionValues(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $optionCollection)
 {
     $type = $attribute->getFrontendInput();
     if ($type === 'select' || $type === 'multiselect') {
         $defaultValues = explode(',', $attribute->getDefaultValue());
         $inputType = $type === 'select' ? 'radio' : 'checkbox';
     } else {
         $defaultValues = [];
         $inputType = '';
     }
     $values = [];
     $isSystemAttribute = is_array($optionCollection);
     foreach ($optionCollection as $option) {
         $bunch = $isSystemAttribute ? $this->_prepareSystemAttributeOptionValues($option, $inputType, $defaultValues) : $this->_prepareUserDefinedAttributeOptionValues($option, $inputType, $defaultValues);
         foreach ($bunch as $value) {
             $values[] = new \Magento\Framework\Object($value);
         }
     }
     return $values;
 }
开发者ID:nja78,项目名称:magento2,代码行数:25,代码来源:Options.php


示例16: getMediaEntriesDataCollection

 /**
  * @param Product $product
  * @param AbstractAttribute $attribute
  * @return array
  */
 protected function getMediaEntriesDataCollection(Product $product, AbstractAttribute $attribute)
 {
     $attributeCode = $attribute->getAttributeCode();
     $mediaData = $product->getData($attributeCode);
     if (!empty($mediaData['images']) && is_array($mediaData['images'])) {
         return $mediaData['images'];
     }
     return [];
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:14,代码来源:ExternalVideoEntryProcessor.php


示例17: getFlatUpdateSelect

 /**
  * Retrieve Select For Flat Attribute update
  *
  * @param AbstractAttribute $attribute
  * @param int $storeId
  * @return Select
  */
 public function getFlatUpdateSelect(AbstractAttribute $attribute, $storeId)
 {
     $connection = $this->getConnection();
     $joinConditionTemplate = "%s.entity_id=%s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
     $joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', \Magento\Store\Model\Store::DEFAULT_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= ' AND e.child_id = t1.entity_id';
     }
     $valueExpr = $connection->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
     /** @var $select Select */
     $select = $connection->select()->joinLeft(['t1' => $attribute->getBackend()->getTable()], $joinCondition, [])->joinLeft(['t2' => $attribute->getBackend()->getTable()], sprintf($joinConditionTemplate, 't1', 't2', 't2', 't2', 't2', $storeId), [$attribute->getAttributeCode() => $valueExpr]);
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child = ?", 0);
     }
     return $select;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:23,代码来源:Attribute.php


示例18: isAttributeStatic

 /**
  * Check whether the attribute is a real field in entity table
  * Rewrited for EAV Collection
  *
  * @param integer|string|\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @return bool
  */
 public function isAttributeStatic($attribute)
 {
     $attributeCode = null;
     if ($attribute instanceof \Magento\Eav\Model\Entity\Attribute\AttributeInterface) {
         $attributeCode = $attribute->getAttributeCode();
     } elseif (is_string($attribute)) {
         $attributeCode = $attribute;
     } elseif (is_numeric($attribute)) {
         $attributeCode = $this->getAttribute($attribute)->getAttributeCode();
     }
     if ($attributeCode) {
         $columns = $this->getAllTableColumns();
         if (in_array($attributeCode, $columns)) {
             return true;
         }
     }
     return false;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:Flat.php


示例19: _getLastSimilarAttributeValueIncrement

 /**
  * Return increment needed for SKU uniqueness
  *
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @param Product $object
  * @return int
  */
 protected function _getLastSimilarAttributeValueIncrement($attribute, $object)
 {
     $connection = $this->getAttribute()->getEntity()->getConnection();
     $select = $connection->select();
     $value = $object->getData($attribute->getAttributeCode());
     $bind = ['attribute_code' => trim($value) . '-%'];
     $select->from($this->getTable(), $attribute->getAttributeCode())->where($attribute->getAttributeCode() . ' LIKE :attribute_code')->order(['entity_id DESC', $attribute->getAttributeCode() . ' ASC'])->limit(1);
     $data = $connection->fetchOne($select, $bind);
     return abs((int) str_replace($value, '', $data));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:Sku.php


示例20: _insertAttribute

 /**
  * Insert entity attribute value
  *
  * @param \Magento\Framework\Object $object
  * @param AbstractAttribute $attribute
  * @param mixed $value
  * @return $this
  */
 protected function _insertAttribute($object, $attribute, $value)
 {
     /**
      * save required attributes in global scope every time if store id different from default
      */
     $storeId = (int) $this->_storeManager->getStore($object->getStoreId())->getId();
     if ($this->getDefaultStoreId() != $storeId) {
         if ($attribute->getIsRequired() || $attribute->getIsRequiredInAdminStore()) {
             $table = $attribute->getBackend()->getTable();
             $select = $this->_getReadAdapter()->select()->from($table)->where('entity_type_id = ?', $attribute->getEntityTypeId())->where('attribute_id = ?', $attribute->getAttributeId())->where('store_id = ?', $this->getDefaultStoreId())->where('entity_id = ?', $object->getEntityId());
             $row = $this->_getReadAdapter()->fetchOne($select);
             if (!$row) {
                 $data = new \Magento\Framework\Object(array('entity_type_id' => $attribute->getEntityTypeId(), 'attribute_id' => $attribute->getAttributeId(), 'store_id' => $this->getDefaultStoreId(), 'entity_id' => $object->getEntityId(), 'value' => $this->_prepareValueForSave($value, $attribute)));
                 $bind = $this->_prepareDataForTable($data, $table);
                 $this->_getWriteAdapter()->insertOnDuplicate($table, $bind, array('value'));
             }
         }
     }
     return $this->_saveAttributeValue($object, $attribute, $value);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:28,代码来源:AbstractResource.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Framework\AuthorizationInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Entity\Attribute类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap