예제 #1
0
 protected function setUp()
 {
     $this->entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getBehavior', 'getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope', 'getConnection'], [], '', false);
     $this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], [], '', false);
     $select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $select->expects($this->any())->method('from')->will($this->returnSelf());
     $select->expects($this->any())->method('where')->will($this->returnSelf());
     $select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $adapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $adapter->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $select->expects($this->any())->method('getAdapter')->willReturn($adapter);
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($select));
     $this->connection->expects($this->any())->method('fetchPairs')->will($this->returnValue(['1' => '1', '2' => '2']));
     $this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->resource = $this->getMock('Magento\\Framework\\App\\Resource', ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->attrSetColFac = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->setCollection = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->attrSetColFac->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     $this->prodAttrColFac = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
     $attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\Collection', [], [], '', false);
     $attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->prodAttrColFac->expects($this->any())->method('create')->will($this->returnValue($attrCollection));
     $this->params = [0 => $this->entityModel, 1 => 'bundle'];
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->bundle = $this->objectManagerHelper->getObject('Magento\\BundleImportExport\\Model\\Import\\Product\\Type\\Bundle', ['attrSetColFac' => $this->attrSetColFac, 'prodAttrColFac' => $this->prodAttrColFac, 'resource' => $this->resource, 'params' => $this->params]);
 }
예제 #2
0
 /**
  * Retrieve list of product templates with search part contained in label
  *
  * @param string $labelPart
  * @return array
  */
 public function getSuggestedTemplates($labelPart)
 {
     $product = $this->_coreRegistry->registry('product');
     $entityType = $product->getResource()->getEntityType();
     $labelPart = $this->_resourceHelper->addLikeEscape($labelPart, ['position' => 'any']);
     /** @var \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection $collection */
     $collection = $this->_setColFactory->create();
     $collection->setEntityTypeFilter($entityType->getId())->addFieldToFilter('attribute_set_name', ['like' => $labelPart])->addFieldToSelect('attribute_set_id', 'id')->addFieldToSelect('attribute_set_name', 'label')->setOrder('attribute_set_name', \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection::SORT_ORDER_ASC);
     return $collection->getData();
 }
예제 #3
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->setCollectionFactory = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->setCollection = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->setCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $item = new \Magento\Framework\Object(['id' => 1, 'attribute_set_name' => 'Default', '_attribute_set' => 'Default']);
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([$item]));
     $this->attrCollectionFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
     $this->attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\Collection', ['setAttributeSetFilter'], [], '', false);
     $superAttributes = [];
     foreach ($this->_getSuperAttributes() as $superAttribute) {
         $item = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', ['isStatic'], $superAttribute, '', false);
         $item->setData($superAttribute);
         $item->method('isStatic')->will($this->returnValue(false));
         $superAttributes[] = $item;
     }
     $this->attrCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->attrCollection));
     $this->attrCollection->expects($this->any())->method('setAttributeSetFilter')->will($this->returnValue($superAttributes));
     $this->_entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getNewSku', 'getOldSku', 'getNextBunch', 'isRowAllowedToImport', 'getConnection', 'getAttrSetIdToName', 'getAttributeOptions'], [], '', false);
     $this->params = [0 => $this->_entityModel, 1 => 'configurable'];
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->_connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', ['from', 'where', 'joinLeft', 'getAdapter'], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $this->_connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $adapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $adapter->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $this->select->expects($this->any())->method('getAdapter')->willReturn($adapter);
     $this->_connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->_connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->_connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->_connection->expects($this->any())->method('fetchPairs')->will($this->returnValue([]));
     $this->resource = $this->getMock('\\Magento\\Framework\\App\\Resource', ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->_connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->_entityModel->expects($this->any())->method('getConnection')->will($this->returnValue($this->_connection));
     $this->productCollectionFactory = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\CollectionFactory', ['create'], [], '', false);
     $this->productCollection = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\Collection', ['addFieldToFilter', 'addAttributeToSelect'], [], '', false);
     $products = [];
     $testProducts = [['id' => 1, 'attribute_set_id' => 4, 'testattr2' => 1, 'testattr3' => 1], ['id' => 2, 'attribute_set_id' => 4, 'testattr2' => 1, 'testattr3' => 1], ['id' => 20, 'attribute_set_id' => 4, 'testattr2' => 1, 'testattr3' => 1]];
     foreach ($testProducts as $product) {
         $item = $this->getMock('\\Magento\\Framework\\Object', ['getAttributeSetId'], [], '', false);
         $item->setData($product);
         $item->expects($this->any())->method('getAttributeSetId')->willReturn(4);
         $products[] = $item;
     }
     $this->productCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->productCollection));
     $this->productCollection->expects($this->any())->method('addFieldToFilter')->will($this->returnValue($this->productCollection));
     $this->productCollection->expects($this->any())->method('addAttributeToSelect')->will($this->returnValue($products));
     $this->_entityModel->expects($this->any())->method('getAttributeOptions')->will($this->returnValue(['attr2val1' => '1', 'attr2val2' => '2', 'attr2val3' => '3', 'testattr3v1' => '4', 'testattr30v1' => '4', 'testattr3v2' => '5', 'testattr3v3' => '6']));
     $this->configurable = $this->objectManagerHelper->getObject('Magento\\ConfigurableImportExport\\Model\\Import\\Product\\Type\\Configurable', ['attrSetColFac' => $this->setCollectionFactory, 'prodAttrColFac' => $this->attrCollectionFactory, 'params' => $this->params, 'resource' => $this->resource, 'productColFac' => $this->productCollectionFactory]);
 }
예제 #4
0
 protected function setUp()
 {
     $this->setCollectionFactory = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->setCollection = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->setCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     $this->attrCollectionFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\CollectionFactory', [], [], '', false);
     $this->entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope'], [], '', false);
     $this->params = [0 => $this->entityModel, 1 => 'grouped'];
     $this->links = $this->getMock('Magento\\GroupedImportExport\\Model\\Import\\Product\\Type\\Grouped\\Links', [], [], '', false);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->grouped = $this->objectManagerHelper->getObject('Magento\\GroupedImportExport\\Model\\Import\\Product\\Type\\Grouped', ['attrSetColFac' => $this->setCollectionFactory, 'prodAttrColFac' => $this->attrCollectionFactory, 'params' => $this->params, 'links' => $this->links]);
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function getList()
 {
     $sets = array();
     $attributeSetsCollection = $this->setCollectionFactory->create()->setEntityTypeFilter($this->eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId())->load();
     /** @var $attributeSet \Magento\Eav\Model\Resource\Entity\Attribute\Set */
     foreach ($attributeSetsCollection as $attributeSet) {
         $this->attributeSetBuilder->setId($attributeSet->getId());
         $this->attributeSetBuilder->setName($attributeSet->getAttributeSetName());
         $this->attributeSetBuilder->setSortOrder($attributeSet->getSortOrder());
         $sets[] = $this->attributeSetBuilder->create();
     }
     return $sets;
 }
예제 #6
0
 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->_eavConfig = $this->getMock('Magento\\Eav\\Model\\Config', array('getEntityType', 'getEntityTypeId'), array(), '', false);
     $this->_eavConfig->expects($this->atLeastOnce())->method('getEntityType')->with($this->equalTo('catalog_product'))->will($this->returnSelf());
     $this->_eavConfig->expects($this->atLeastOnce())->method('getEntityTypeId')->will($this->returnValue('1'));
     $this->_optionModel = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\Option', array(), array(), '', false);
     $this->_optionFactory = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\OptionFactory', array('create'), array(), '', false);
     $this->_optionFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->_optionModel));
     $this->_storeManager = $this->getMock('\\Magento\\Store\\Model\\StoreManager', array('getWebsites', 'getStores'), array(), '', false);
     $this->_storeManager->expects($this->atLeastOnce())->method('getWebsites')->will($this->returnValue(array()));
     $this->_storeManager->expects($this->atLeastOnce())->method('getStores')->will($this->returnValue(array()));
     $this->_setCol = $this->getMock('\\Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection', array('setEntityTypeFilter'), array(), '', false);
     $this->_setCol->expects($this->atLeastOnce())->method('setEntityTypeFilter')->with($this->equalTo('1'))->will($this->returnValue(array()));
     $this->_setColFactory = $this->getMock('\\Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\CollectionFactory', array('create'), array(), '', false);
     $this->_setColFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->_setCol));
     $this->_importConfig = $this->getMock('\\Magento\\ImportExport\\Model\\Import\\Config', array('getEntityTypes'), array(), '', false);
     $this->_importConfig->expects($this->atLeastOnce())->method('getEntityTypes')->with('catalog_product')->will($this->returnValue(array()));
     $this->_categoryCol = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Category\\Collection', array('addNameToResult'), array(), '', false);
     $this->_categoryCol->expects($this->atLeastOnce())->method('addNameToResult')->will($this->returnValue(array()));
     $this->_categoryColFactory = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Category\\CollectionFactory', array('create'), array(), '', false);
     $this->_categoryColFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->_categoryCol));
     $this->_product = $this->getMock('\\Magento\\Catalog\\Model\\Product', array('getProductEntitiesInfo', '__wakeup'), array(), '', false);
     $this->_product->expects($this->atLeastOnce())->method('getProductEntitiesInfo')->with($this->equalTo(array('entity_id', 'type_id', 'attribute_set_id', 'sku')))->will($this->returnValue(array()));
     $this->_productFactory = $this->getMock('\\Magento\\Catalog\\Model\\ProductFactory', array('create'), array(), '', false);
     $this->_productFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->_product));
     $this->_customerGroupService = $this->getMock('Magento\\Customer\\Service\\V1\\CustomerGroupService', array('getGroups'), array(), '', false);
     $this->_customerGroupService->expects($this->atLeastOnce())->method('getGroups')->will($this->returnValue(array()));
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_model = $objectManager->getObject('\\Magento\\CatalogImportExport\\Model\\Import\\Product', array('config' => $this->_eavConfig, 'optionFactory' => $this->_optionFactory, 'storeManager' => $this->_storeManager, 'setColFactory' => $this->_setColFactory, 'importConfig' => $this->_importConfig, 'categoryColFactory' => $this->_categoryColFactory, 'productFactory' => $this->_productFactory, 'customerGroupService' => $this->_customerGroupService));
 }
 /**
  * {@inheritdoc}
  */
 public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
 {
     /** @var \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection $collection */
     $collection = $this->collectionFactory->create();
     /** The only possible/meaningful search criteria for attribute set is entity type code */
     $entityTypeCode = $this->getEntityTypeCode($searchCriteria);
     if ($entityTypeCode !== null) {
         $collection->setEntityTypeFilter($this->eavConfig->getEntityType($entityTypeCode)->getId());
     }
     $collection->setCurPage($searchCriteria->getCurrentPage());
     $collection->setPageSize($searchCriteria->getPageSize());
     $searchResults = $this->searchResultsFactory->create();
     $searchResults->setSearchCriteria($searchCriteria);
     $searchResults->setItems($collection->getItems());
     $searchResults->setTotalCount($collection->getSize());
     return $searchResults;
 }
예제 #8
0
파일: Sku.php 프로젝트: aiesh/magento2
 /**
  * Define Cooser Grid Columns and filters
  *
  * @return $this
  */
 protected function _prepareColumns()
 {
     $this->addColumn('in_products', array('header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'sku', 'use_index' => true));
     $this->addColumn('entity_id', array('header' => __('ID'), 'sortable' => true, 'width' => '60px', 'index' => 'entity_id'));
     $this->addColumn('type', array('header' => __('Type'), 'width' => '60px', 'index' => 'type_id', 'type' => 'options', 'options' => $this->_catalogType->getOptionArray()));
     $sets = $this->_eavAttSetCollection->create()->setEntityTypeFilter($this->_catalogProduct->create()->getResource()->getTypeId())->load()->toOptionHash();
     $this->addColumn('set_name', array('header' => __('Attribute Set'), 'width' => '100px', 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets));
     $this->addColumn('chooser_sku', array('header' => __('SKU'), 'name' => 'chooser_sku', 'width' => '80px', 'index' => 'sku'));
     $this->addColumn('chooser_name', array('header' => __('Product'), 'name' => 'chooser_name', 'index' => 'name'));
     return parent::_prepareColumns();
 }
예제 #9
0
 /**
  * Prepare grid columns
  *
  * @return $this
  */
 protected function _prepareColumns()
 {
     $this->addColumn('id', ['header' => __('ID'), 'sortable' => true, 'width' => '60px', 'index' => 'entity_id']);
     $this->addColumn('name', ['header' => __('Product'), 'index' => 'name', 'column_css_class' => 'name']);
     $sets = $this->_eavCollectionFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash();
     $this->addColumn('type', ['header' => __('Type'), 'width' => '60px', 'index' => 'type_id', 'type' => 'options', 'options' => $this->_productType->getOptionArray()]);
     $this->addColumn('set_name', ['header' => __('Attribute Set'), 'width' => '100px', 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets]);
     $this->addColumn('sku', ['header' => __('SKU'), 'width' => '80px', 'index' => 'sku', 'column_css_class' => 'sku']);
     $this->addColumn('price', ['header' => __('Price'), 'align' => 'center', 'type' => 'currency', 'currency_code' => $this->_getStore()->getDefaultCurrencyCode(), 'rate' => $this->_getStore()->getBaseCurrency()->getRate($this->_getStore()->getDefaultCurrencyCode()), 'index' => 'price']);
     return parent::_prepareColumns();
 }
예제 #10
0
 /**
  * @return $this
  */
 protected function _initAttributeSets()
 {
     $attributeSetOne = $this->getMockBuilder('\\Magento\\Eav\\Model\\Entity\\Attribute\\Set')->disableOriginalConstructor()->getMock();
     $attributeSetOne->expects($this->any())->method('getAttributeSetName')->willReturn('attributeSet1');
     $attributeSetOne->expects($this->any())->method('getId')->willReturn('1');
     $attributeSetTwo = $this->getMockBuilder('\\Magento\\Eav\\Model\\Entity\\Attribute\\Set')->disableOriginalConstructor()->getMock();
     $attributeSetTwo->expects($this->any())->method('getAttributeSetName')->willReturn('attributeSet2');
     $attributeSetTwo->expects($this->any())->method('getId')->willReturn('2');
     $attributeSetCol = [$attributeSetOne, $attributeSetTwo];
     $collection = $this->getMockBuilder('\\Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection')->disableOriginalConstructor()->getMock();
     $collection->expects($this->once())->method('setEntityTypeFilter')->with(self::ENTITY_TYPE_ID)->willReturn($attributeSetCol);
     $this->_setColFactory->expects($this->once())->method('create')->willReturn($collection);
     return $this;
 }
예제 #11
0
 /**
  * @return $this
  */
 public function loadAttributeSets()
 {
     if ($this->_attributeSetsById) {
         return $this;
     }
     $attributeSetCollection = $this->_setCollectionFactory->create()->load();
     $this->_attributeSetsById = [];
     $this->_attributeSetsByName = [];
     foreach ($attributeSetCollection as $id => $attributeSet) {
         $entityTypeId = $attributeSet->getEntityTypeId();
         $name = $attributeSet->getAttributeSetName();
         $this->_attributeSetsById[$entityTypeId][$id] = $name;
         $this->_attributeSetsByName[$entityTypeId][strtolower($name)] = $id;
     }
     return $this;
 }
예제 #12
0
 /**
  * Initialize attributes parameters for all attributes' sets.
  *
  * @return $this
  */
 protected function _initAttributes()
 {
     // temporary storage for attributes' parameters to avoid double querying inside the loop
     $attributesCache = [];
     foreach ($this->_attrSetColFac->create()->setEntityTypeFilter($this->_entityModel->getEntityTypeId()) as $attributeSet) {
         foreach ($this->_prodAttrColFac->create()->setAttributeSetFilter($attributeSet->getId()) as $attribute) {
             $attributeCode = $attribute->getAttributeCode();
             $attributeId = $attribute->getId();
             if ($attribute->getIsVisible() || in_array($attributeCode, $this->_forcedAttributesCodes)) {
                 if (!isset($attributesCache[$attributeId])) {
                     $attributesCache[$attributeId] = ['id' => $attributeId, 'code' => $attributeCode, 'is_global' => $attribute->getIsGlobal(), 'is_required' => $attribute->getIsRequired(), 'is_unique' => $attribute->getIsUnique(), 'frontend_label' => $attribute->getFrontendLabel(), 'is_static' => $attribute->isStatic(), 'apply_to' => $attribute->getApplyTo(), 'type' => \Magento\ImportExport\Model\Import::getAttributeType($attribute), 'default_value' => strlen($attribute->getDefaultValue()) ? $attribute->getDefaultValue() : null, 'options' => $this->_entityModel->getAttributeOptions($attribute, $this->_indexValueAttributes)];
                 }
                 $this->_addAttributeParams($attributeSet->getAttributeSetName(), $attributesCache[$attributeId], $attribute);
             }
         }
     }
     return $this;
 }
예제 #13
0
 /**
  * Get array with attribute setes which available for some target country
  *
  * @param  string $targetCountry
  * @return array
  */
 protected function _getAttributeSetsArray($targetCountry)
 {
     $entityType = $this->_productFactory->create()->getResource()->getEntityType();
     $collection = $this->_eavCollectionFactory->create()->setEntityTypeFilter($entityType->getId());
     $ids = [];
     $itemType = $this->getItemType();
     if (!($itemType instanceof \Magento\Framework\Object && $itemType->getId())) {
         $typesCollection = $this->_typeCollectionFactory->create()->addCountryFilter($targetCountry)->load();
         foreach ($typesCollection as $type) {
             $ids[] = $type->getAttributeSetId();
         }
     }
     $result = ['' => ''];
     foreach ($collection as $attributeSet) {
         if (!in_array($attributeSet->getId(), $ids)) {
             $result[$attributeSet->getId()] = $attributeSet->getAttributeSetName();
         }
     }
     return $result;
 }
예제 #14
0
 /**
  * Initialize attribute sets code-to-id pairs.
  *
  * @return $this
  */
 protected function _initAttributeSets()
 {
     foreach ($this->_setColFactory->create()->setEntityTypeFilter($this->_entityTypeId) as $attributeSet) {
         $this->_attrSetNameToId[$attributeSet->getAttributeSetName()] = $attributeSet->getId();
         $this->_attrSetIdToName[$attributeSet->getId()] = $attributeSet->getAttributeSetName();
     }
     return $this;
 }