<?php

namespace Webkul\Magento2Bundle\Entity;

/**
 * Magento2MappedAttributeRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class MappedAttributeRepository extends \Doctrine\ORM\EntityRepository
{
    public function getAllMappingValues()
    {
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('m.magentoCode, m.akeneoCode')
            ->from($this->getEntityName(), 'm');
        $results = $qb->getQuery()->getArrayResult();

        return $this->indexValues($results);
    }

    private function indexValues($results)
    {
        $output = [];
        foreach ($results as $result) {
            $output[$result['magentoCode']] = $result['akeneoCode'];
        }

        return $output;
    }
}
