Esempio n. 1
0
 /**
  * Loads the values from a product model
  *
  * @param \Magento\Catalog\Model\Product $productModel
  * @return void
  */
 protected function _populateBuilderWithAttributes(\Magento\Catalog\Model\Product $productModel)
 {
     $attributes = array();
     foreach ($this->productBuilder->getCustomAttributesCodes() as $attrCode) {
         $value = $productModel->getDataUsingMethod($attrCode);
         $value = $value ? $value : $productModel->getData($attrCode);
         if (null !== $value) {
             if ($attrCode != 'entity_id') {
                 $attributes[$attrCode] = $value;
             }
         }
     }
     $this->productBuilder->populateWithArray($attributes);
     return;
 }
Esempio n. 2
0
 /**
  * Loads the values from a product model
  *
  * @param \Magento\Catalog\Model\Product $productModel
  * @return void
  */
 protected function populateBuilderWithAttributes(\Magento\Catalog\Model\Product $productModel)
 {
     $attributes = array();
     foreach ($productModel->getAttributes() as $attribute) {
         $attrCode = $attribute->getAttributeCode();
         $value = $productModel->getDataUsingMethod($attrCode) ?: $productModel->getData($attrCode);
         if (null !== $value) {
             if ($attrCode != 'entity_id') {
                 $attributes[$attrCode] = $value;
             }
         }
     }
     $attributes[ProductDataObject::STORE_ID] = $productModel->getStoreId();
     $this->productBuilder->populateWithArray($attributes);
     return;
 }