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

PHP Flat\Processor类代码示例

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

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



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

示例1: processValue

 /**
  * Process flat enabled mode change
  *
  * @return void
  */
 public function processValue()
 {
     if ((bool) $this->getValue() != (bool) $this->getOldValue()) {
         if ((bool) $this->getValue()) {
             $this->indexerState->loadByIndexer(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::INDEXER_ID);
             $this->indexerState->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID);
             $this->indexerState->save();
         } else {
             $this->_productFlatIndexerProcessor->getIndexer()->setScheduled(false);
         }
     }
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:17,代码来源:Mode.php


示例2: testReindexListForce

 public function testReindexListForce()
 {
     $ids = [1];
     $this->_stateMock->expects($this->once())->method('isFlatEnabled')->willReturn(true);
     $indexerMock = $this->getMockBuilder('Magento\\Indexer\\Model\\Indexer')->disableOriginalConstructor()->getMock();
     $this->indexerRegistryMock->expects($this->any())->method('get')->with(Processor::INDEXER_ID)->willReturn($indexerMock);
     $indexerMock->expects($this->any())->method('isScheduled')->willReturn(true);
     $indexerMock->expects($this->any())->method('reindexList')->with($ids)->willReturnSelf();
     $this->_model->reindexList($ids, true);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:ProcessorTest.php


示例3: afterDeleteCommit

 /**
  * Init indexing process after catalog eav attribute delete commit
  *
  * @return $this
  */
 public function afterDeleteCommit()
 {
     parent::afterDeleteCommit();
     if ($this->_isOriginalEnabledInFlat()) {
         $this->_productFlatIndexerProcessor->markIndexerAsInvalid();
     }
     if ($this->_isOriginalIndexable()) {
         $this->_indexerEavProcessor->markIndexerAsInvalid();
     }
     return $this;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:16,代码来源:Attribute.php


示例4: testReindex

 /**
  * @param $productChanged
  * @param $isScheduled
  * @param $productFlatCount
  * @param $categoryIndexerCount
  *
  * @dataProvider getProductReindexProvider
  */
 public function testReindex($productChanged, $isScheduled, $productFlatCount, $categoryIndexerCount)
 {
     $this->model->setData('entity_id', 1);
     $this->_catalogProduct->expects($this->once())->method('isDataForProductCategoryIndexerWasChanged')->willReturn($productChanged);
     if ($productChanged) {
         $this->indexerRegistryMock->expects($this->exactly($productFlatCount))->method('get')->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID)->will($this->returnValue($this->categoryIndexerMock));
         $this->categoryIndexerMock->expects($this->any())->method('isScheduled')->will($this->returnValue($isScheduled));
         $this->categoryIndexerMock->expects($this->exactly($categoryIndexerCount))->method('reindexRow');
     }
     $this->productFlatProcessor->expects($this->exactly($productFlatCount))->method('reindexRow');
     $this->model->reindex();
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:20,代码来源:ProductTest.php


示例5: reindex

 /**
  * Init indexing process after product save
  *
  * @return void
  */
 public function reindex()
 {
     if ($this->_catalogProduct->isDataForProductCategoryIndexerWasChanged($this) || $this->isDeleted()) {
         $productCategoryIndexer = $this->indexerRegistry->get(Indexer\Product\Category::INDEXER_ID);
         if (!$productCategoryIndexer->isScheduled()) {
             $productCategoryIndexer->reindexRow($this->getId());
         }
     }
     $this->_productFlatIndexerProcessor->reindexRow($this->getEntityId());
 }
开发者ID:nblair,项目名称:magescotch,代码行数:15,代码来源:Product.php


示例6: beforeSave

 /**
  * Before save handler
  *
  * @param \Magento\Store\Model\ResourceModel\Group $subject
  * @param \Magento\Framework\Model\AbstractModel $object
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeSave(\Magento\Store\Model\ResourceModel\Group $subject, \Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getId() || $object->dataHasChangedFor('root_category_id')) {
         $this->_productFlatIndexerProcessor->markIndexerAsInvalid();
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:StoreGroup.php


示例7: afterImportSource

 /**
  * After import handler
  *
  * @param \Magento\ImportExport\Model\Import $subject
  * @param Object $import
  *
  * @return mixed
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterImportSource(\Magento\ImportExport\Model\Import $subject, $import)
 {
     $this->_productFlatIndexerProcessor->markIndexerAsInvalid();
     return $import;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:Import.php


示例8: execute

 /**
  * Update product attributes
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function execute()
 {
     if (!$this->_validateProducts()) {
         return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['_current' => true]);
     }
     /* Collect Data */
     $inventoryData = $this->getRequest()->getParam('inventory', []);
     $attributesData = $this->getRequest()->getParam('attributes', []);
     $websiteRemoveData = $this->getRequest()->getParam('remove_website_ids', []);
     $websiteAddData = $this->getRequest()->getParam('add_website_ids', []);
     /* Prepare inventory data item options (use config settings) */
     $options = $this->_objectManager->get('Magento\\CatalogInventory\\Api\\StockConfigurationInterface')->getConfigItemOptions();
     foreach ($options as $option) {
         if (isset($inventoryData[$option]) && !isset($inventoryData['use_config_' . $option])) {
             $inventoryData['use_config_' . $option] = 0;
         }
     }
     try {
         $storeId = $this->attributeHelper->getSelectedStoreId();
         if ($attributesData) {
             $dateFormat = $this->_objectManager->get('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface')->getDateFormat(\IntlDateFormatter::SHORT);
             foreach ($attributesData as $attributeCode => $value) {
                 $attribute = $this->_objectManager->get('Magento\\Eav\\Model\\Config')->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode);
                 if (!$attribute->getAttributeId()) {
                     unset($attributesData[$attributeCode]);
                     continue;
                 }
                 if ($attribute->getBackendType() == 'datetime') {
                     if (!empty($value)) {
                         $filterInput = new \Zend_Filter_LocalizedToNormalized(['date_format' => $dateFormat]);
                         $filterInternal = new \Zend_Filter_NormalizedToLocalized(['date_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT]);
                         $value = $filterInternal->filter($filterInput->filter($value));
                     } else {
                         $value = null;
                     }
                     $attributesData[$attributeCode] = $value;
                 } elseif ($attribute->getFrontendInput() == 'multiselect') {
                     // Check if 'Change' checkbox has been checked by admin for this attribute
                     $isChanged = (bool) $this->getRequest()->getPost($attributeCode . '_checkbox');
                     if (!$isChanged) {
                         unset($attributesData[$attributeCode]);
                         continue;
                     }
                     if (is_array($value)) {
                         $value = implode(',', $value);
                     }
                     $attributesData[$attributeCode] = $value;
                 }
             }
             $this->_objectManager->get('Magento\\Catalog\\Model\\Product\\Action')->updateAttributes($this->attributeHelper->getProductIds(), $attributesData, $storeId);
         }
         if ($inventoryData) {
             // TODO why use ObjectManager?
             /** @var \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry */
             $stockRegistry = $this->_objectManager->create('Magento\\CatalogInventory\\Api\\StockRegistryInterface');
             /** @var \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository */
             $stockItemRepository = $this->_objectManager->create('Magento\\CatalogInventory\\Api\\StockItemRepositoryInterface');
             foreach ($this->attributeHelper->getProductIds() as $productId) {
                 $stockItemDo = $stockRegistry->getStockItem($productId, $this->attributeHelper->getStoreWebsiteId($storeId));
                 if (!$stockItemDo->getProductId()) {
                     $inventoryData[] = $productId;
                 }
                 $stockItemId = $stockItemDo->getId();
                 $this->dataObjectHelper->populateWithArray($stockItemDo, $inventoryData, '\\Magento\\CatalogInventory\\Api\\Data\\StockItemInterface');
                 $stockItemDo->setItemId($stockItemId);
                 $stockItemRepository->save($stockItemDo);
             }
             $this->_stockIndexerProcessor->reindexList($this->attributeHelper->getProductIds());
         }
         if ($websiteAddData || $websiteRemoveData) {
             /* @var $actionModel \Magento\Catalog\Model\Product\Action */
             $actionModel = $this->_objectManager->get('Magento\\Catalog\\Model\\Product\\Action');
             $productIds = $this->attributeHelper->getProductIds();
             if ($websiteRemoveData) {
                 $actionModel->updateWebsites($productIds, $websiteRemoveData, 'remove');
             }
             if ($websiteAddData) {
                 $actionModel->updateWebsites($productIds, $websiteAddData, 'add');
             }
             $this->_eventManager->dispatch('catalog_product_to_website_change', ['products' => $productIds]);
         }
         $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', count($this->attributeHelper->getProductIds())));
         $this->_productFlatIndexerProcessor->reindexList($this->attributeHelper->getProductIds());
         if ($this->_catalogProduct->isDataForPriceIndexerWasChanged($attributesData) || !empty($websiteRemoveData) || !empty($websiteAddData)) {
             $this->_productPriceIndexerProcessor->reindexList($this->attributeHelper->getProductIds());
         }
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Something went wrong while updating the product(s) attributes.'));
     }
     return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['store' => $this->attributeHelper->getSelectedStoreId()]);
//.........这里部分代码省略.........
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:101,代码来源:Save.php


示例9: execute

 /**
  * Update product attributes
  *
  * @return void
  */
 public function execute()
 {
     if (!$this->_validateProducts()) {
         return;
     }
     /* Collect Data */
     $inventoryData = $this->getRequest()->getParam('inventory', array());
     $attributesData = $this->getRequest()->getParam('attributes', array());
     $websiteRemoveData = $this->getRequest()->getParam('remove_website_ids', array());
     $websiteAddData = $this->getRequest()->getParam('add_website_ids', array());
     /* Prepare inventory data item options (use config settings) */
     $options = $this->_objectManager->get('Magento\\CatalogInventory\\Helper\\Data')->getConfigItemOptions();
     foreach ($options as $option) {
         if (isset($inventoryData[$option]) && !isset($inventoryData['use_config_' . $option])) {
             $inventoryData['use_config_' . $option] = 0;
         }
     }
     try {
         if ($attributesData) {
             $dateFormat = $this->_objectManager->get('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface')->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT);
             $storeId = $this->attributeHelper->getSelectedStoreId();
             foreach ($attributesData as $attributeCode => $value) {
                 $attribute = $this->_objectManager->get('Magento\\Eav\\Model\\Config')->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode);
                 if (!$attribute->getAttributeId()) {
                     unset($attributesData[$attributeCode]);
                     continue;
                 }
                 if ($attribute->getBackendType() == 'datetime') {
                     if (!empty($value)) {
                         $filterInput = new \Zend_Filter_LocalizedToNormalized(array('date_format' => $dateFormat));
                         $filterInternal = new \Zend_Filter_NormalizedToLocalized(array('date_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT));
                         $value = $filterInternal->filter($filterInput->filter($value));
                     } else {
                         $value = null;
                     }
                     $attributesData[$attributeCode] = $value;
                 } elseif ($attribute->getFrontendInput() == 'multiselect') {
                     // Check if 'Change' checkbox has been checked by admin for this attribute
                     $isChanged = (bool) $this->getRequest()->getPost($attributeCode . '_checkbox');
                     if (!$isChanged) {
                         unset($attributesData[$attributeCode]);
                         continue;
                     }
                     if (is_array($value)) {
                         $value = implode(',', $value);
                     }
                     $attributesData[$attributeCode] = $value;
                 }
             }
             $this->_objectManager->get('Magento\\Catalog\\Model\\Product\\Action')->updateAttributes($this->attributeHelper->getProductIds(), $attributesData, $storeId);
         }
         if ($inventoryData) {
             /** @var \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService */
             $stockItemService = $this->_objectManager->create('Magento\\CatalogInventory\\Service\\V1\\StockItemService');
             foreach ($this->_helper->getProductIds() as $productId) {
                 $stockItemDo = $stockItemService->getStockItem($productId);
                 if (!$stockItemDo->getProductId()) {
                     $inventoryData[] = $productId;
                 }
                 $stockItemService->saveStockItem($this->stockItemBuilder->mergeDataObjectWithArray($stockItemDo, $inventoryData));
             }
             $this->_stockIndexerProcessor->reindexList($this->_helper->getProductIds());
         }
         if ($websiteAddData || $websiteRemoveData) {
             /* @var $actionModel \Magento\Catalog\Model\Product\Action */
             $actionModel = $this->_objectManager->get('Magento\\Catalog\\Model\\Product\\Action');
             $productIds = $this->attributeHelper->getProductIds();
             if ($websiteRemoveData) {
                 $actionModel->updateWebsites($productIds, $websiteRemoveData, 'remove');
             }
             if ($websiteAddData) {
                 $actionModel->updateWebsites($productIds, $websiteAddData, 'add');
             }
             $this->_eventManager->dispatch('catalog_product_to_website_change', array('products' => $productIds));
             $this->messageManager->addNotice(__('Please refresh "Catalog URL Rewrites" and "Product Attributes" in System -> ' . '<a href="%1">Index Management</a>.', $this->getUrl('adminhtml/process/list')));
         }
         $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', count($this->attributeHelper->getProductIds())));
         $this->_productFlatIndexerProcessor->reindexList($this->attributeHelper->getProductIds());
         if ($this->_catalogProduct->isDataForPriceIndexerWasChanged($attributesData) || !empty($websiteRemoveData) || !empty($websiteAddData)) {
             $this->_productPriceIndexerProcessor->reindexList($this->attributeHelper->getProductIds());
         }
     } catch (\Magento\Framework\Model\Exception $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Something went wrong while updating the product(s) attributes.'));
     }
     $this->_redirect('catalog/product/', array('store' => $this->attributeHelper->getSelectedStoreId()));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:93,代码来源:Save.php


示例10: reindex

 /**
  * Init indexing process after product save
  *
  * @return void
  */
 public function reindex()
 {
     $this->_productFlatIndexerProcessor->reindexRow($this->getEntityId());
     if (!$this->getCategoryIndexer()->isScheduled()) {
         $this->getCategoryIndexer()->reindexRow($this->getId());
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Product.php


示例11: testProductUpdate

 /**
  * @magentoDataFixture Magento/Catalog/_files/row_fixture.php
  * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1
  * @magentoAppArea frontend
  */
 public function testProductUpdate()
 {
     $this->markTestSkipped('Incomplete due to MAGETWO-21369');
     $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\CategoryFactory');
     $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Block\\Product\\ListProduct');
     $this->_processor->getIndexer()->setScheduled(false);
     $this->assertFalse($this->_processor->getIndexer()->isScheduled(), 'Indexer is in scheduled mode when turned to update on save mode');
     $this->_processor->reindexAll();
     $this->_product->load(1);
     $this->_product->setName('Updated Product');
     $this->_product->save();
     $category = $categoryFactory->create()->load(9);
     $layer = $listProduct->getLayer();
     $layer->setCurrentCategory($category);
     /** @var \Magento\Catalog\Model\Resource\Product\Collection $productCollection */
     $productCollection = $layer->getProductCollection();
     $this->assertTrue($productCollection->isEnabledFlat(), 'Product collection is not using flat resource when flat is on');
     $this->assertEquals(2, $productCollection->count(), 'Product collection items count must be exactly 2');
     foreach ($productCollection as $product) {
         /** @var $product \Magento\Catalog\Model\Product */
         if ($product->getId() == 1) {
             $this->assertEquals('Updated Product', $product->getName(), 'Product name from flat does not match with updated name');
         }
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:30,代码来源:RowTest.php


示例12: testAddNewStoreGroup

 /**
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  * @magentoAppArea adminhtml
  * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1
  */
 public function testAddNewStoreGroup()
 {
     /** @var \Magento\Store\Model\Group $storeGroup */
     $storeGroup = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Store\\Model\\Group');
     $storeGroup->setData(['website_id' => 1, 'name' => 'New Store Group', 'root_category_id' => 2, 'group_id' => null]);
     $storeGroup->save();
     $this->assertTrue($this->_processor->getIndexer()->isInvalid());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:ProcessorTest.php


示例13: testReindexAll

 /**
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  */
 public function testReindexAll()
 {
     $this->assertTrue($this->_state->isFlatEnabled());
     $this->_processor->reindexAll();
     $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Model\\CategoryFactory');
     $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Block\\Product\\ListProduct');
     $category = $categoryFactory->create()->load(2);
     $layer = $listProduct->getLayer();
     $layer->setCurrentCategory($category);
     $productCollection = $layer->getProductCollection();
     $this->assertCount(1, $productCollection);
     /** @var $product \Magento\Catalog\Model\Product */
     foreach ($productCollection as $product) {
         $this->assertEquals('Simple Product', $product->getName());
         $this->assertEquals('Short description', $product->getShortDescription());
     }
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:23,代码来源:FullTest.php


示例14: testProductsUpdate

 /**
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  */
 public function testProductsUpdate()
 {
     $this->markTestSkipped('Should be fixed in MAGETWO-25641');
     $this->_product->load(1);
     $this->_processor->reindexList(array($this->_product->getId()));
     $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Model\\CategoryFactory');
     $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Block\\Product\\ListProduct');
     $category = $categoryFactory->create()->load(2);
     $layer = $listProduct->getLayer();
     $layer->setCurrentCategory($category);
     $productCollection = $layer->getProductCollection();
     $this->assertCount(1, $productCollection);
     /** @var $product \Magento\Catalog\Model\Product */
     foreach ($productCollection as $product) {
         $this->assertEquals($this->_product->getName(), $product->getName());
         $this->assertEquals($this->_product->getShortDescription(), $product->getShortDescription());
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:24,代码来源:RowsTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Product\Option类代码示例发布时间:2022-05-23
下一篇:
PHP Model\ProductFactory类代码示例发布时间: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