本文整理汇总了PHP中Magento\Eav\Model\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testLike
/**
* Test a search using 'like' condition
*/
public function testLike()
{
$attributeCode = 'description';
$attributeCodeId = 42;
$attribute = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
$attribute->expects($this->once())->method('getAttributeCode')->willReturn($attributeCode);
$this->eavConfig->expects($this->once())->method('getAttribute')->with(Product::ENTITY, $attributeCodeId)->willReturn($attribute);
$filtersData = ['catalog_product_entity_text' => [$attributeCodeId => ['like' => 'search text']]];
$this->filterBuilder->expects($this->once())->method('setField')->with($attributeCode)->willReturn($this->filterBuilder);
$this->filterBuilder->expects($this->once())->method('setValue')->with('search text')->willReturn($this->filterBuilder);
$filter = $this->getMock('Magento\\Framework\\Api\\Filter');
$this->filterBuilder->expects($this->once())->method('create')->willReturn($filter);
$criteria = $this->getMock('Magento\\Framework\\Api\\Search\\SearchCriteria', [], [], '', false);
$this->criteriaBuilder->expects($this->once())->method('create')->willReturn($criteria);
$criteria->expects($this->once())->method('setRequestName')->with('advanced_search_container');
$tempTable = $this->getMock('Magento\\Framework\\DB\\Ddl\\Table', [], [], '', false);
$temporaryStorage = $this->getMock('Magento\\Framework\\Search\\Adapter\\Mysql\\TemporaryStorage', [], [], '', false);
$temporaryStorage->expects($this->once())->method('storeApiDocuments')->willReturn($tempTable);
$this->temporaryStorageFactory->expects($this->once())->method('create')->willReturn($temporaryStorage);
$searchResult = $this->getMock('Magento\\Framework\\Api\\Search\\SearchResultInterface', [], [], '', false);
$this->search->expects($this->once())->method('search')->willReturn($searchResult);
// addFieldsToFilter will load filters,
// then loadWithFilter will trigger _renderFiltersBefore code in Advanced/Collection
$this->assertSame($this->advancedCollection, $this->advancedCollection->addFieldsToFilter($filtersData)->loadWithFilter());
}
开发者ID:Doability,项目名称:magento2dev,代码行数:28,代码来源:CollectionTest.php
示例2: getEntityTypeId
/**
* Retrieve catalog_product entity type id
*
* @return int
*/
public function getEntityTypeId()
{
if ($this->_entityTypeId === null) {
$this->_entityTypeId = (int) $this->_eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId();
}
return $this->_entityTypeId;
}
开发者ID:halk,项目名称:recowise-magento2-demo,代码行数:12,代码来源:Config.php
示例3: upgrade
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
if (version_compare($context->getVersion(), '2.0.6', '<')) {
$this->upgradeVersionTwoZeroSix($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$this->upgradeVersionTwoZeroOne($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.2') < 0) {
$this->upgradeVersionTwoZeroTwo($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.3', '<')) {
$this->upgradeVersionTwoZeroThree($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.4', '<')) {
$this->upgradeVersionTwoZeroFour($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.5', '<')) {
$this->upgradeVersionTwoZeroFive($customerSetup, $setup);
}
if (version_compare($context->getVersion(), '2.0.6', '<')) {
$setup->getConnection()->delete($setup->getTable('customer_form_attribute'), ['form_code = ?' => 'checkout_register']);
}
if (version_compare($context->getVersion(), '2.0.7', '<')) {
$this->upgradeVersionTwoZeroSeven($customerSetup);
$this->upgradeCustomerPasswordResetlinkExpirationPeriodConfig($setup);
}
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
$indexer->reindexAll();
$this->eavConfig->clear();
$setup->endSetup();
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:39,代码来源:UpgradeData.php
示例4: upgrade
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$entityAttributes = ['customer' => ['website_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'created_in' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'email' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'group_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'dob' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'taxvat' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'confirmation' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'created_at' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'gender' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false]], 'customer_address' => ['company' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'street' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'city' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'country_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'region' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'region_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'postcode' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'telephone' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'fax' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true]]];
$this->upgradeAttributes($entityAttributes, $customerSetup);
}
if (version_compare($context->getVersion(), '2.0.2') < 0) {
$entityTypeId = $customerSetup->getEntityTypeId(Customer::ENTITY);
$attributeId = $customerSetup->getAttributeId($entityTypeId, 'gender');
$option = ['attribute_id' => $attributeId, 'values' => [3 => 'Not Specified']];
$customerSetup->addAttributeOption($option);
}
if (version_compare($context->getVersion(), '2.0.3', '<')) {
$entityAttributes = ['customer_address' => ['region_id' => ['is_used_in_grid' => false, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => false], 'firstname' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'lastname' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true]]];
$this->upgradeAttributes($entityAttributes, $customerSetup);
}
if (version_compare($context->getVersion(), '2.0.4', '<')) {
$customerSetup->addAttribute(Customer::ENTITY, 'updated_at', ['type' => 'static', 'label' => 'Updated At', 'input' => 'date', 'required' => false, 'sort_order' => 87, 'visible' => false, 'system' => false]);
}
if (version_compare($context->getVersion(), '2.0.5', '<')) {
$this->upgradeHash($setup);
$entityAttributes = ['customer_address' => ['fax' => ['is_visible' => false, 'is_system' => false]]];
$this->upgradeAttributes($entityAttributes, $customerSetup);
}
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
$indexer->reindexAll();
$this->eavConfig->clear();
$setup->endSetup();
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:36,代码来源:UpgradeData.php
示例5: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->logger->log('Installing sales rules:');
$file = 'SalesRule/sales_rules.csv';
$fileName = $this->fixtureHelper->getPath($file);
$csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']);
$attribute = $this->eavConfig->getAttribute('catalog_product', 'sku');
if ($attribute->getIsUsedForPromoRules() == 0) {
$attribute->setIsUsedForPromoRules('1')->save();
}
foreach ($csvReader as $row) {
/** @var \Magento\SalesRule\Model\Resource\Rule\Collection $ruleCollection */
$ruleCollection = $this->ruleCollectionFactory->create();
$ruleCollection->addFilter('name', $row['name']);
if ($ruleCollection->count() > 0) {
continue;
}
$row['customer_group_ids'] = $this->catalogRule->getGroupIds();
$row['website_ids'] = $this->catalogRule->getWebsiteIds();
$row['conditions_serialized'] = $this->catalogRule->convertSerializedData($row['conditions_serialized']);
$row['actions_serialized'] = $this->catalogRule->convertSerializedData($row['actions_serialized']);
/** @var \Magento\SalesRule\Model\Rule $rule */
$rule = $this->ruleFactory->create();
$rule->loadPost($row);
$rule->save();
$this->logger->logInline('.');
}
}
开发者ID:vinai-drive-by-commits,项目名称:magento2-sample-data,代码行数:31,代码来源:Rule.php
示例6: install
/**
* @param array $productFixtures
* @param array $galleryFixtures
* @throws \Exception
*/
public function install(array $productFixtures, array $galleryFixtures)
{
$this->eavConfig->clear();
$this->setGalleryFixtures($galleryFixtures);
$product = $this->productFactory->create();
foreach ($productFixtures as $fileName) {
$fileName = $this->fixtureManager->getFixture($fileName);
if (!file_exists($fileName)) {
continue;
}
$rows = $this->csvReader->getData($fileName);
$header = array_shift($rows);
foreach ($rows as $row) {
$data = [];
foreach ($row as $key => $value) {
$data[$header[$key]] = $value;
}
$row = $data;
$attributeSetId = $this->catalogConfig->getAttributeSetId(4, $row['attribute_set']);
$this->converter->setAttributeSetId($attributeSetId);
$data = $this->converter->convertRow($row);
$product->unsetData();
$product->setData($data);
$product->setTypeId($this->productType)->setAttributeSetId($attributeSetId)->setWebsiteIds([$this->storeManager->getDefaultStoreView()->getWebsiteId()])->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)->setStockData(['is_in_stock' => 1, 'manage_stock' => 0])->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID);
if (empty($data['visibility'])) {
$product->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH);
}
$this->prepareProduct($product, $data);
$product->save();
$this->installGallery($product);
}
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:38,代码来源:Product.php
示例7: afterSave
/**
* Save EAV default value after save
*
* @return $this
*/
public function afterSave()
{
$result = parent::afterSave();
$attributeObject = $this->eavConfig->getAttribute('customer', 'disable_auto_group_change');
$attributeObject->setData('default_value', $this->getValue());
$attributeObject->save();
return $result;
}
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:DisableAutoGroupAssignDefault.php
示例8: getAllAttributeCodes
/**
* Get all attribute codes for a given entity type and attribute set
*
* @param string $entityType
* @param int $attributeSetId
* @param string|null $storeId
* @return array Attribute codes
*/
public function getAllAttributeCodes($entityType, $attributeSetId = 0, $storeId = null)
{
if (null === $storeId) {
$storeId = $this->storeManager->getStore()->getId();
}
$object = new \Magento\Framework\DataObject(['store_id' => $storeId, 'attribute_set_id' => $attributeSetId]);
return $this->eavConfig->getEntityAttributeCodes($entityType, $object);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:AttributeMetadataDataProvider.php
示例9: doesEntityHaveOverriddenUrlKeyForStore
/**
* Check that entity has overridden url key for specific store
*
* @param int $storeId
* @param int $entityId
* @param string $entityType
* @throws \InvalidArgumentException
* @return bool
*/
public function doesEntityHaveOverriddenUrlKeyForStore($storeId, $entityId, $entityType)
{
$attribute = $this->eavConfig->getAttribute($entityType, 'url_key');
if (!$attribute) {
throw new \InvalidArgumentException(sprintf('Cannot retrieve attribute for entity type "%s"', $entityType));
}
$select = $this->connection->select()->from($attribute->getBackendTable(), 'store_id')->where('attribute_id = ?', $attribute->getId())->where('entity_id = ?', $entityId);
return in_array($storeId, $this->connection->fetchCol($select));
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:18,代码来源:StoreViewService.php
示例10: __construct
/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\ImportExport\Model\Export\Factory $collectionFactory
* @param \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory $resourceColFactory
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Eav\Model\Config $eavConfig
* @param array $data
*/
public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $eavConfig, array $data = [])
{
$this->_localeDate = $localeDate;
parent::__construct($scopeConfig, $storeManager, $collectionFactory, $resourceColFactory, $data);
if (isset($data['entity_type_id'])) {
$this->_entityTypeId = $data['entity_type_id'];
} else {
$this->_entityTypeId = $eavConfig->getEntityType($this->getEntityTypeCode())->getEntityTypeId();
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:AbstractEav.php
示例11: testAfterSave
public function testAfterSave()
{
$value = true;
$attributeMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute')->setMethods(['save', 'setData'])->disableOriginalConstructor()->getMockForAbstractClass();
$this->eavConfigMock->expects($this->once())->method('getAttribute')->with('customer', 'disable_auto_group_change')->willReturn($attributeMock);
$attributeMock->expects($this->once())->method('setData')->with('default_value', $value);
$attributeMock->expects($this->once())->method('save');
$this->model->setValue($value);
$this->assertEquals($this->model, $this->model->afterSave());
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:DisableAutoGroupAssignDefaultTest.php
示例12: __construct
/**
* @param FixtureHelper $fixtureHelper
* @param CsvReaderFactory $csvReaderFactory
* @param ProductFactory $productFactory
* @param GalleryAttribute $galleryAttribute
* @param \Magento\Eav\Model\Config $eavConfig
* @param Logger $logger
*/
public function __construct(FixtureHelper $fixtureHelper, CsvReaderFactory $csvReaderFactory, ProductFactory $productFactory, GalleryAttribute $galleryAttribute, \Magento\Eav\Model\Config $eavConfig, Logger $logger)
{
$this->fixtureHelper = $fixtureHelper;
$this->galleryAttribute = $galleryAttribute;
$this->productFactory = $productFactory;
$this->csvReaderFactory = $csvReaderFactory;
$this->mediaAttribute = $eavConfig->getAttribute('catalog_product', 'media_gallery');
$this->logger = $logger;
$this->loadFixtures();
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:Gallery.php
示例13: setUp
protected function setUp()
{
$this->searchBuilderMock = $this->getMock('Magento\\Framework\\Api\\SearchCriteriaBuilder', [], [], '', false);
$this->filterBuilderMock = $this->getMock('Magento\\Framework\\Api\\FilterBuilder', [], [], '', false);
$this->attributeRepositoryMock = $this->getMock('Magento\\Eav\\Api\\AttributeRepositoryInterface', [], [], '', false);
$this->searchResultMock = $this->getMock('Magento\\Framework\\Api\\SearchResultsInterface', ['getItems', 'getSearchCriteria', 'getTotalCount', 'setItems', 'setSearchCriteria', 'setTotalCount', '__wakeup'], [], '', false);
$this->eavConfigMock = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
$this->eavConfigMock->expects($this->any())->method('getEntityType')->willReturn(new \Magento\Framework\DataObject(['default_attribute_set_id' => 3]));
$this->model = (new ObjectManager($this))->getObject('Magento\\Catalog\\Model\\Category\\AttributeRepository', ['searchCriteriaBuilder' => $this->searchBuilderMock, 'filterBuilder' => $this->filterBuilderMock, 'eavAttributeRepository' => $this->attributeRepositoryMock, 'eavConfig' => $this->eavConfigMock]);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:AttributeRepositoryTest.php
示例14: __construct
/**
* Constructor
*
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param EavValidationRules $eavValidationRules
* @param CustomerCollectionFactory $customerCollectionFactory
* @param Config $eavConfig
* @param FilterPool $filterPool
* @param array $meta
* @param array $data
*/
public function __construct($name, $primaryFieldName, $requestFieldName, EavValidationRules $eavValidationRules, CustomerCollectionFactory $customerCollectionFactory, Config $eavConfig, FilterPool $filterPool, array $meta = [], array $data = [])
{
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
$this->eavValidationRules = $eavValidationRules;
$this->collection = $customerCollectionFactory->create();
$this->collection->addAttributeToSelect('*');
$this->eavConfig = $eavConfig;
$this->filterPool = $filterPool;
$this->meta['customer']['fields'] = $this->getAttributesMeta($this->eavConfig->getEntityType('customer'));
$this->meta['address']['fields'] = $this->getAttributesMeta($this->eavConfig->getEntityType('customer_address'));
}
开发者ID:IlyaGluschenko,项目名称:protection,代码行数:24,代码来源:DataProvider.php
示例15: validateSkeletonSet
/**
* @param int $skeletonId
* @return void
* @throws StateException
*/
protected function validateSkeletonSet($skeletonId)
{
try {
$skeletonSet = $this->attributeSetRepository->get($skeletonId);
$productEntityId = $this->eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId();
if ($skeletonSet->getEntityTypeId() != $productEntityId) {
throw new StateException(__('Can not create attribute set based on non product attribute set.'));
}
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
throw new StateException(__('Can not create attribute set based on not existing attribute set'));
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:SetManagement.php
示例16: doesEntityHaveOverriddenUrlAttributeForStore
/**
* Check that entity has overridden url attribute for specific store
*
* @param int $storeId
* @param int $entityId
* @param string $entityType
* @param mixed $attributeName
* @throws \InvalidArgumentException
* @return bool
*/
protected function doesEntityHaveOverriddenUrlAttributeForStore($storeId, $entityId, $entityType, $attributeName)
{
$attribute = $this->eavConfig->getAttribute($entityType, $attributeName);
if (!$attribute) {
throw new \InvalidArgumentException(sprintf('Cannot retrieve attribute for entity type "%s"', $entityType));
}
$linkFieldName = $attribute->getEntity()->getLinkField();
if (!$linkFieldName) {
$linkFieldName = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
}
$select = $this->connection->select()->from(['e' => $attribute->getEntity()->getEntityTable()], [])->join(['e_attr' => $attribute->getBackendTable()], "e.{$linkFieldName} = e_attr.{$linkFieldName}", 'store_id')->where('e_attr.attribute_id = ?', $attribute->getId())->where('e.entity_id = ?', $entityId);
return in_array($storeId, $this->connection->fetchCol($select));
}
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:23,代码来源:StoreViewService.php
示例17: afterGetUsedProductCollection
/**
* Returns Configurable Products Collection with added swatch attributes
*
* @param ConfigurableProduct $subject
* @param Collection $result
* @return Collection
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetUsedProductCollection(ConfigurableProductType $subject, Collection $result)
{
$attributeCodes = ['image'];
$entityType = $result->getEntity()->getType();
foreach ($this->eavConfig->getEntityAttributeCodes($entityType) as $code) {
$attribute = $this->eavConfig->getAttribute($entityType, $code);
if ($this->swatchHelper->isVisualSwatch($attribute) || $this->swatchHelper->isTextSwatch($attribute)) {
$attributeCodes[] = $code;
}
}
$result->addAttributeToSelect($attributeCodes);
return $result;
}
开发者ID:rafaelstz,项目名称:magento2,代码行数:22,代码来源:Configurable.php
示例18: afterDelete
/**
* Processing object after delete data
*
* @return \Magento\Framework\Model\AbstractModel
*/
public function afterDelete()
{
$result = parent::afterDelete();
if ($this->getScope() == \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITES) {
$attribute = $this->_eavConfig->getAttribute('customer_address', 'street');
$website = $this->_storeManager->getWebsite($this->getScopeCode());
$attribute->setWebsite($website);
$attribute->load($attribute->getId());
$attribute->setData('scope_multiline_count', null);
$attribute->save();
}
return $result;
}
开发者ID:opexsw,项目名称:magento2,代码行数:18,代码来源:Street.php
示例19: createConfigurableProduct
protected function createConfigurableProduct()
{
$productId1 = 10;
$productId2 = 20;
$label = "color";
$this->configurableAttribute = $this->eavConfig->getAttribute('catalog_product', 'test_configurable');
$this->assertNotNull($this->configurableAttribute);
$options = $this->getConfigurableAttributeOptions();
$this->assertEquals(2, count($options));
$configurableProductOptions = [["attribute_id" => $this->configurableAttribute->getId(), "label" => $label, "position" => 0, "values" => [["value_index" => $options[0]['option_id']], ["value_index" => $options[1]['option_id']]]]];
$product = ["sku" => self::CONFIGURABLE_PRODUCT_SKU, "name" => self::CONFIGURABLE_PRODUCT_SKU, "type_id" => "configurable", "price" => 50, 'attribute_set_id' => 4, "custom_attributes" => [["attribute_code" => $this->configurableAttribute->getAttributeCode(), "value" => $options[0]['option_id']]], "extension_attributes" => ["configurable_product_options" => $configurableProductOptions, "configurable_product_links" => [$productId1, $productId2]]];
$response = $this->createProduct($product);
return $response;
}
开发者ID:tingyeeh,项目名称:magento2,代码行数:14,代码来源:ProductRepositoryTest.php
示例20: getAttributesUsedInRecommender
/**
* Retrieve Attributes used in product listing
*
* @return array
*/
public function getAttributesUsedInRecommender()
{
if ($this->_usedInRecommender === null) {
$this->_usedInRecommender = [];
$entityType = \Magento\Catalog\Model\Product::ENTITY;
$attributesData = $this->_getResource()->getAttributesUsedInRecommender();
$this->_eavConfig->importAttributesData($entityType, $attributesData);
foreach ($attributesData as $attributeData) {
$attributeCode = $attributeData['attribute_code'];
$this->_usedInRecommender[$attributeCode] = $this->_eavConfig->getAttribute($entityType, $attributeCode);
}
}
return $this->_usedInRecommender;
}
开发者ID:halk,项目名称:recowise-magento2-demo,代码行数:19,代码来源:Config.php
注:本文中的Magento\Eav\Model\Config类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论