當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Attribute::getBackendTypeByInput方法代碼示例

本文整理匯總了PHP中Magento\Eav\Model\Entity\Attribute::getBackendTypeByInput方法的典型用法代碼示例。如果您正苦於以下問題:PHP Attribute::getBackendTypeByInput方法的具體用法?PHP Attribute::getBackendTypeByInput怎麽用?PHP Attribute::getBackendTypeByInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Eav\Model\Entity\Attribute的用法示例。


在下文中一共展示了Attribute::getBackendTypeByInput方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: testGetBackendTypeByInput

 /**
  * @param string $givenFrontendInput
  * @param string $expectedBackendType
  * @dataProvider dataGetBackendTypeByInput
  */
 public function testGetBackendTypeByInput($givenFrontendInput, $expectedBackendType)
 {
     $this->assertEquals($expectedBackendType, $this->_model->getBackendTypeByInput($givenFrontendInput));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:9,代碼來源:AttributeTest.php


注:本文中的Magento\Eav\Model\Entity\Attribute::getBackendTypeByInput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。