Пример #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;
 }
Пример #2
0
 public function testGetCustomAttributes()
 {
     $expectedAttributesCodes = ['attribute_code_1', 'attribute_code_2'];
     $this->assertEquals($expectedAttributesCodes, $this->_productBuilder->getCustomAttributesCodes());
 }