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


PHP Config::clear方法代码示例

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


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

示例1: 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

示例2: 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

示例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: prepareProduct

 /**
  * @inheritdoc
  */
 protected function prepareProduct($product, $data)
 {
     if ($this->attributeSet !== $data['attribute_set']) {
         $this->attributeSet = $data['attribute_set'];
         $this->eavConfig->clear();
     }
     if (empty($data['associated_product_ids'])) {
         $simpleIds = $this->configurableProductType->generateSimpleProducts($product, $data['variations_matrix']);
     } else {
         $simpleIds = $data['associated_product_ids'];
     }
     $product->setAssociatedProductIds($simpleIds);
     $product->setCanSaveConfigurableAttributes(true);
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:Product.php

示例5: upgrade

 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     /** @var SalesSetup $salesSetup */
     $salesSetup = $this->salesSetupFactory->create(['setup' => $setup]);
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         $salesSetup->updateEntityType(\Magento\Sales\Model\Order::ENTITY, 'entity_model', 'Magento\\Sales\\Model\\ResourceModel\\Order');
         $salesSetup->updateEntityType(\Magento\Sales\Model\Order::ENTITY, 'increment_model', 'Magento\\Eav\\Model\\Entity\\Increment\\NumericValue');
         $salesSetup->updateEntityType('invoice', 'entity_model', 'Magento\\Sales\\Model\\ResourceModel\\Order');
         $salesSetup->updateEntityType('invoice', 'increment_model', 'Magento\\Eav\\Model\\Entity\\Increment\\NumericValue');
         $salesSetup->updateEntityType('creditmemo', 'entity_model', 'Magento\\Sales\\Model\\ResourceModel\\Order\\Creditmemo');
         $salesSetup->updateEntityType('creditmemo', 'increment_model', 'Magento\\Eav\\Model\\Entity\\Increment\\NumericValue');
         $salesSetup->updateEntityType('shipment', 'entity_model', 'Magento\\Sales\\Model\\ResourceModel\\Order\\Shipment');
         $salesSetup->updateEntityType('shipment', 'increment_model', 'Magento\\Eav\\Model\\Entity\\Increment\\NumericValue');
     }
     $this->eavConfig->clear();
     $setup->endSetup();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:UpgradeData.php

示例6: install

 /**
  * @param array $fixtures
  * @throws \Exception
  */
 public function install(array $fixtures)
 {
     $attributeCount = 0;
     foreach ($fixtures 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;
             }
             $data['attribute_set'] = explode("\n", $data['attribute_set']);
             /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
             $attribute = $this->eavConfig->getAttribute('catalog_product', $data['attribute_code']);
             if (!$attribute) {
                 $attribute = $this->attributeFactory->create();
             }
             $frontendLabel = explode("\n", $data['frontend_label']);
             if (count($frontendLabel) > 1) {
                 $data['frontend_label'] = [];
                 $data['frontend_label'][\Magento\Store\Model\Store::DEFAULT_STORE_ID] = $frontendLabel[0];
                 $data['frontend_label'][$this->storeManager->getDefaultStoreView()->getStoreId()] = $frontendLabel[1];
             }
             $data['option'] = $this->getOption($attribute, $data);
             $data['source_model'] = $this->productHelper->getAttributeSourceModelByInputType($data['frontend_input']);
             $data['backend_model'] = $this->productHelper->getAttributeBackendModelByInputType($data['frontend_input']);
             $data += ['is_filterable' => 0, 'is_filterable_in_search' => 0, 'apply_to' => []];
             $data['backend_type'] = $attribute->getBackendTypeByInput($data['frontend_input']);
             $attribute->addData($data);
             $attribute->setIsUserDefined(1);
             $attribute->setEntityTypeId($this->getEntityTypeId());
             $attribute->save();
             $attributeId = $attribute->getId();
             if (is_array($data['attribute_set'])) {
                 foreach ($data['attribute_set'] as $setName) {
                     $setName = trim($setName);
                     $attributeCount++;
                     $attributeSet = $this->processAttributeSet($setName);
                     $attributeGroupId = $attributeSet->getDefaultGroupId();
                     $attribute = $this->attributeFactory->create();
                     $attribute->setId($attributeId)->setAttributeGroupId($attributeGroupId)->setAttributeSetId($attributeSet->getId())->setEntityTypeId($this->getEntityTypeId())->setSortOrder($attributeCount + 999)->save();
                 }
             }
         }
     }
     $this->eavConfig->clear();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:55,代码来源:Attribute.php

示例7: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->logger->log('Installing catalog attributes:');
     $attributeCount = 0;
     foreach ($this->moduleList->getNames() as $moduleName) {
         $fileName = substr($moduleName, strpos($moduleName, "_") + 1) . '/attributes.csv';
         $fileName = $this->fixtureHelper->getPath($fileName);
         if (!$fileName) {
             continue;
         }
         $csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']);
         foreach ($csvReader as $data) {
             $data['attribute_set'] = explode("\n", $data['attribute_set']);
             /** @var \Magento\Catalog\Model\Resource\Eav\Attribute $attribute */
             $attribute = $this->eavConfig->getAttribute('catalog_product', $data['attribute_code']);
             if (!$attribute) {
                 $attribute = $this->attributeFactory->create();
             }
             $frontendLabel = explode("\n", $data['frontend_label']);
             if (count($frontendLabel) > 1) {
                 $data['frontend_label'] = [];
                 $data['frontend_label'][\Magento\Store\Model\Store::DEFAULT_STORE_ID] = $frontendLabel[0];
                 $data['frontend_label'][$this->storeManager->getStoreId()] = $frontendLabel[1];
             }
             $data['option'] = $this->getOption($attribute, $data);
             $data['source_model'] = $this->productHelper->getAttributeSourceModelByInputType($data['frontend_input']);
             $data['backend_model'] = $this->productHelper->getAttributeBackendModelByInputType($data['frontend_input']);
             $data += ['is_filterable' => 0, 'is_filterable_in_search' => 0, 'apply_to' => []];
             $data['backend_type'] = $attribute->getBackendTypeByInput($data['frontend_input']);
             $attribute->addData($data);
             $attribute->setIsUserDefined(1);
             $attribute->setEntityTypeId($this->getEntityTypeId());
             $attribute->save();
             $attributeId = $attribute->getId();
             if (is_array($data['attribute_set'])) {
                 foreach ($data['attribute_set'] as $setName) {
                     $setName = trim($setName);
                     $attributeCount++;
                     $attributeSet = $this->processAttributeSet($setName);
                     $attributeGroupId = $attributeSet->getDefaultGroupId();
                     $attribute = $this->attributeFactory->create();
                     $attribute->setId($attributeId)->setAttributeGroupId($attributeGroupId)->setAttributeSetId($attributeSet->getId())->setEntityTypeId($this->getEntityTypeId())->setSortOrder($attributeCount + 999)->save();
                 }
             }
             $this->logger->logInline('.');
         }
     }
     $this->eavConfig->clear();
 }
开发者ID:ktplKunj,项目名称:TestMagento,代码行数:52,代码来源:Attribute.php

示例8: testClear

 public function testClear()
 {
     $this->cacheMock->expects($this->once())->method('clean')->with($this->equalTo([\Magento\Eav\Model\Cache\Type::CACHE_TAG, \Magento\Eav\Model\Entity\Attribute::CACHE_TAG]));
     $this->config->clear();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:5,代码来源:ConfigTest.php


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