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


PHP Attribute::getId方法代码示例

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


在下文中一共展示了Attribute::getId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = $this->catalogAttributeFactory->create();
     $data = $this->params;
     $data['attribute_code'] = $this->code;
     $data['frontend_label'] = array(\Magento\Store\Model\Store::DEFAULT_STORE_ID => $this->primaryLabel);
     $data['frontend_input'] = $this->inputType;
     $data['entity_type_id'] = $this->entityTypeId;
     $data['is_user_defined'] = 1;
     $data['source_model'] = $this->productHelper->getAttributeSourceModelByInputType($this->inputType);
     $data['backend_model'] = $this->productHelper->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:Doability,项目名称:magento2dev,代码行数:33,代码来源:Builder.php

示例2: findWhereAttributeIs

 /**
  * Return entities where attribute value is
  *
  * @param array|int $entityIdsFilter
  * @param \Magento\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:pavelnovitsky,项目名称:magento2,代码行数:14,代码来源:Category.php

示例3: findWhereAttributeIs

 /**
  * Return entities where attribute value is
  *
  * @param array|int $entityIdsFilter
  * @param \Magento\Eav\Model\Entity\Attribute $attribute
  * @param mixed $expectedValue
  * @return array
  */
 public function findWhereAttributeIs($entityIdsFilter, $attribute, $expectedValue)
 {
     $linkField = $this->getLinkField();
     $bind = ['attribute_id' => $attribute->getId(), 'value' => $expectedValue];
     $selectEntities = $this->getConnection()->select()->from(['ce' => $this->getTable('catalog_category_entity')], ['entity_id'])->joinLeft(['ci' => $attribute->getBackend()->getTable()], "ci.{$linkField} = ce.{$linkField} AND attribute_id = :attribute_id", ['value'])->where('ci.value = :value')->where('ce.entity_id IN (?)', $entityIdsFilter);
     return $this->getConnection()->fetchCol($selectEntities, $bind);
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:15,代码来源:Category.php

示例4: checkIsAlreadyInSet

 private function checkIsAlreadyInSet()
 {
     /* @var $collection \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection */
     $collection = $this->attributeFactory->create()->getResourceCollection()->setAttributeSetFilter($this->setId)->addFieldToFilter('entity_attribute.attribute_id', $this->attributeObj->getId());
     return $collection->getSize() > 0;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:6,代码来源:Relation.php

示例5: next

 /**
  * {@inheritDoc}
  */
 public function next()
 {
     \next($this->products);
     if (\key($this->products) === null) {
         // check if storage has more items to process
         $this->products = $this->dataProvider->getSearchableProducts($this->storeId, $this->staticFields, $this->productIds, $this->lastProductId);
         if (!count($this->products)) {
             $this->isValid = false;
             return;
         }
         $productAttributes = [];
         $this->productRelations = [];
         foreach ($this->products as $productData) {
             $this->lastProductId = $productData['entity_id'];
             $productAttributes[$productData['entity_id']] = $productData['entity_id'];
             $productChildren = $this->dataProvider->getProductChildIds($productData['entity_id'], $productData['type_id']);
             $this->productRelations[$productData['entity_id']] = $productChildren;
             if ($productChildren) {
                 foreach ($productChildren as $productChildId) {
                     $productAttributes[$productChildId] = $productChildId;
                 }
             }
         }
         \reset($this->products);
         $this->productAttributes = $this->dataProvider->getProductAttributes($this->storeId, $productAttributes, $this->dynamicFields);
     }
     $productData = \current($this->products);
     if (!isset($this->productAttributes[$productData['entity_id']])) {
         $this->next();
         return;
     }
     $productAttr = $this->productAttributes[$productData['entity_id']];
     if (!isset($productAttr[$this->visibility->getId()]) || !in_array($productAttr[$this->visibility->getId()], $this->allowedVisibility)) {
         $this->next();
         return;
     }
     if (!isset($productAttr[$this->status->getId()]) || !in_array($productAttr[$this->status->getId()], $this->statusIds)) {
         $this->next();
         return;
     }
     $productIndex = [$productData['entity_id'] => $productAttr];
     $hasChildren = false;
     $productChildren = $this->productRelations[$productData['entity_id']];
     if ($productChildren) {
         foreach ($productChildren as $productChildId) {
             if (isset($this->productAttributes[$productChildId])) {
                 $productChildAttr = $this->productAttributes[$productChildId];
                 if (!isset($productChildAttr[$this->status->getId()]) || !in_array($productChildAttr[$this->status->getId()], $this->statusIds)) {
                     continue;
                 }
                 $hasChildren = true;
                 $productIndex[$productChildId] = $productChildAttr;
             }
         }
     }
     if ($productChildren !== null && !$hasChildren) {
         $this->next();
         return;
     }
     $index = $this->dataProvider->prepareProductIndex($productIndex, $productData, $this->storeId);
     $this->current = $index;
     $this->key = $productData['entity_id'];
 }
开发者ID:vv-team,项目名称:foodo,代码行数:66,代码来源:IndexIterator.php


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