예제 #1
0
 /**
  * Return collection of same attributes for selected products without unique
  *
  * @return \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection
  */
 public function getAttributes()
 {
     if ($this->_attributes === null) {
         $this->_attributes = $this->_eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getAttributeCollection()->addIsNotUniqueFilter()->setInAllAttributeSetsFilter($this->getProductsSetIds());
         if ($this->_excludedAttributes) {
             $this->_attributes->addFieldToFilter('attribute_code', ['nin' => $this->_excludedAttributes]);
         }
         // check product type apply to limitation and remove attributes that impossible to change in mass-update
         $productTypeIds = $this->getProducts()->getProductTypeIds();
         foreach ($this->_attributes as $attribute) {
             /* @var $attribute \Magento\Catalog\Model\Entity\Attribute */
             foreach ($productTypeIds as $productTypeId) {
                 $applyTo = $attribute->getApplyTo();
                 if (count($applyTo) > 0 && !in_array($productTypeId, $applyTo)) {
                     $this->_attributes->removeItemByKey($attribute->getId());
                     break;
                 }
             }
         }
     }
     return $this->_attributes;
 }
예제 #2
0
 /**
  * Clean up attribute collection.
  *
  * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection $collection
  * @return \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection
  */
 public function filterAttributeCollection(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection $collection)
 {
     $collection->load();
     foreach ($collection as $attribute) {
         if (in_array($attribute->getAttributeCode(), $this->_disabledAttrs)) {
             $collection->removeItemByKey($attribute->getId());
         }
     }
     return $collection;
 }
예제 #3
0
 /**
  * Clean up attribute collection.
  *
  * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection $collection
  * @return \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection
  */
 public function filterAttributeCollection(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection $collection)
 {
     $collection->load();
     foreach ($collection as $attribute) {
         if (in_array($attribute->getAttributeCode(), $this->_disabledAttrs)) {
             if (isset($this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_SKIP])) {
                 if ($attribute->getAttributeCode() == ImportAdvancedPricing::COL_TIER_PRICE && in_array($attribute->getId(), $this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_SKIP])) {
                     $this->_passTierPrice = 1;
                 }
             }
             $collection->removeItemByKey($attribute->getId());
         }
     }
     return $collection;
 }