@param array $productData
@param array $attributes

@return array
966609
protected function buildProductVariationAttributes(array &$productData, array $attributes)
    {
        /** @var string $attribute */
        foreach ($attributes as $attribute) {
            $productData['variation_attributes'][] = (string) $attribute;
        }

        return $productData;
    }
31395
private function getExtraProductMergeAttributes(Buyable $product)
    {
        $result = [];
        $cfg    = config(self::EXTRA_PRODUCT_MERGE_ATTRIBUTES_CONFIG_KEY, []);

        if (!is_array($cfg)) {
            throw new InvalidCartConfigurationException(
                sprintf(
                    'The value of `%s` configuration must be an array',
                    self::EXTRA_PRODUCT_MERGE_ATTRIBUTES_CONFIG_KEY
                )
            );
        }

        foreach ($cfg as $attribute) {
            if (!is_string($attribute)) {
                throw new InvalidCartConfigurationException(
                    sprintf(
                        'The configuration `%s` can only contain an array of strings, `%s` given',
                        self::EXTRA_PRODUCT_MERGE_ATTRIBUTES_CONFIG_KEY,
                        gettype($attribute)
                    )
                );
            }

            $result[$attribute] = $product->{$attribute};
        }

        return $result;
    }
737994
public function filterRawAttributes(array $attributes = [], $keys = ['count', 'dn'])
    {
        $attributes = Arr::except($attributes, $keys);

        array_walk($attributes, function (&$value) use ($keys) {
            $value = is_array($value) ?
                $this->filterRawAttributes($value, $keys) :
                $value;
        });

        return $attributes;
    }
1107380
protected function checkAttributeFilters(array $attributes)
	{
		foreach ($attributes as $attrConfig)
		{
			if (empty($attrConfig['filterChain']))
			{
				continue;
			}
			foreach ($attrConfig['filterChain'] as $filter)
			{
				if (substr($filter, 0, 1) !== '#' && !in_array($filter, $this->allowedFilters, true))
				{
					throw new RuntimeException("Filter '$filter' is not allowed in media sites");
				}
			}
		}
	}
105239
private function processConfigAttributes($configAttributes, $attributesFromAttributeSet, $productModel, $attributes)
    {
        foreach ($configAttributes as $attributeCode) {
            //if config attribute is in attribute set
            if (in_array($attributeCode, $attributesFromAttributeSet)) {
                //attribute input type
                $inputType = $this->productResource
                    ->getAttribute($attributeCode)
                    ->getFrontend()
                    ->getInputType();

                //fetch attribute value from product depending on input type
                switch ($inputType) {
                    case 'multiselect':
                    case 'select':
                    case 'dropdown':
                        $value = $productModel->getAttributeText($attributeCode);
                        break;
                    case 'date':
                        $value = $productModel->getData($attributeCode);
                        break;
                    default:
                        $value = $productModel->getData($attributeCode);
                        break;
                }

                $attributes = $this->processAttributeValue($attributes, $value, $attributeCode);
            }
        }
        return $attributes;
    }
430674
private function formatProductAttributes(array $attributes) {

    $formatted = [];

    foreach ($attributes as $name => $value) {
      if (is_string($value)) {
        $valueAsString = $value;
      }
      else {
        // Does the key=>value store module expect serialize?
        // (I would prefer JSON)
        // >> Yes. (But are we using the key=>value store for this?)
        // Can we pass it the object and get 'auto serialize/unserialize'?
        // >> Maybe.
        if (is_array($value) || is_object($value)) {
          $valueAsString = serialize($value);
        }
        else {
          // 'Trust' PHP's type-casting for now.
          $valueAsString = (string) $value;
        }
      }

      $formatted[] = [
        'key' => $name,
        'value' => $valueAsString,
      ];
    }

    return $formatted;
  }
1272133
function productOptionInformation( $objectAttribute, $optionID, $productItem )
    {
        $multioption = $objectAttribute->attribute( 'content' );

        foreach ( $multioption->attribute( 'multioption_list' ) as $multioptionElement )
        {
            foreach ( $multioptionElement['optionlist'] as $option )
            {
                if ( $option['option_id'] != $optionID )
                    continue;

                return array( 'id' => $option['option_id'],
                              'name' => $multioptionElement['name'],
                              'value' => $option['value'],
                              'additional_price' => $option['additional_price'] );
            }
        }
    }
1104007
protected function getSuccessData($attributes = null)
    {
        $rawData = $this->decodeResponseJson()['data'];

        if (is_null($attributes)) {
            return $rawData;
        } elseif (is_string($attributes)) {
            return array_get($rawData, $attributes);
        }

        $data = [];

        foreach ($attributes as $attribute) {
            $data[] = array_get($rawData, $attribute);
        }

        return $data;
    }
1085778
public function __toArray($attributes = array()){

        if( empty($attributes) ){
            $data = $this->_data;
        }else{

            $data = array();
            foreach( $attributes as $attribute ){
                if( isset($this->_data[$attribute]) ){
                    $data[$attribute] = $this->_data[$attribute];
                } else {
                    $data[$attribute] = NULL;
                }
            }

        }

        foreach( $data as $key => $item ){
            if( $item instanceof AppObject ){
                $item = $item->toArray();
                $data[$key] = $item;
            }
        }

        return $data;
    }
1122430
public function _getAttributesArray($attributeSetId)
    {
        $result = [];
        $attributes = $this->attributeCollection->create()
            ->setAttributeSetFilter($attributeSetId)
            ->getItems();

        foreach ($attributes as $attribute) {
            $result[] = $attribute->getAttributeCode();
        }

        return $result;
    }
1028886
public function addProductItemFieldData(ProductItemFieldData $productItemFieldData)
    {
        $productItemFieldData->setProduct($this);

        $this->productItemFieldDatas->add($productItemFieldData);

        return $this;
    }
277331
public function createProductAttribute(
        Attribute $attribute,
        ProductInterface $product,
        AttributeValue $attributeValue
    ) {
        $productAttribute = $this->productAttributeRepository->createNew();
        $productAttribute->setAttribute($attribute);
        $productAttribute->setProduct($product);
        $productAttribute->setAttributeValue($attributeValue);
        $this->entityManager->persist($productAttribute);

        $product->addProductAttribute($productAttribute);

        return $productAttribute;
    }
646465
final public function sort(array $attributes = array())
    {
        $productImage   = $this->find($attributes['movingId']);
        $positionEntity = $this->find($attributes['movedId']);

        if ($productImage instanceof ProductImage) {
            if ($this->fireEvent('sorting', array($productImage)) === false) {
                return false;
            }

            $productImage->setCaller($this);
            $productImage->{$attributes['type']}($positionEntity);

            $this->fireEvent('sorted', array($productImage));

            return $productImage;
        }

        throw new Exception(sprintf(Exception::CANT_UPDATE_MODEL,
            'Subbly\\Model\\Product',
            $this->name()
        ));
    }
126601
public function syncWithProductType(ProductTypeContract $productType, $attributeIds, array $requiredAttributes = [])
    {
        $attributeIds = is_array($attributeIds) ? $attributeIds : [$attributeIds];

        $pivot = [];
        foreach ($attributeIds as $id) {
            $pivot[$id] = ['required' => in_array($id, $requiredAttributes)];
        }

        return $productType->attributes()->sync($pivot);
    }
1112721
protected function _getProductData(Product $product, ProductIterator $children)
    {
        $categoryIds = $this->categoryRepository->getCategoryIds($product);
        $productData = new IndexDocument(array(
            'id' => $product->getSolrId(), // primary identifier, must be unique
            'product_id' => $product->getId(),
            'category' => $categoryIds, // @todo get category ids from parent anchor categories as well
            'category_name_t_mv' => $this->categoryRepository->getCategoryNames($categoryIds, $product->getStoreId()),
            'store_id' => $product->getStoreId(),
            'content_type' => self::CONTENT_TYPE,
            'is_visible_in_catalog_i' => intval($product->isVisibleInCatalog()),
            'is_visible_in_search_i' => intval($product->isVisibleInSearch()),
            'has_special_price_i' => intval($product->hasSpecialPrice()),
            'is_in_stock_i' => intval($product->isInStock()),
        ));

        $this->_addBoostToProductData($product, $productData);

        $this->_addFacetsToProductData($product, $productData, $children);

        $this->_addSearchDataToProductData($product, $productData, $children);

        $this->_addSortingDataToProductData($product, $productData);

        $this->_addResultHtmlToProductData($product, $productData);

        $this->_addCategoryProductPositionsToProductData($product, $productData);

        $this->eventDispatcher->dispatch('integernet_solr_get_product_data', array(
            'product' => $product,
            'product_data' => $productData,
            'children' => $children,
        ));

        return $productData;
    }
467306
protected function mutableAttributesToArray(array $attributes)
    {
        foreach ($attributes as $key => $value) {
            if ($this->hasGetterMutator($key)) {
                $attributes[$key] = $this->mutableMutate($key, $value, 'getter');
            }
        }

        return $attributes;
    }
897165
public function attributes(array $attributes)
    {
        foreach ($attributes as $attribute => &$data) {
            $data = implode(' ', (array) $data);
            $data = $attribute . '="' . htmlspecialchars($data, ENT_QUOTES, 'UTF-8') . '"';
        }

        return empty($attributes) ? '' : ' ' . implode(' ', $attributes);
    }