Add Product Fixtures, Shopper Theme

Add Product Fixtures, Shopper Theme

Code to use the ``fixtures``

    $fixturePath = str_replace('vendor\nilead\core-bundle\Nilead\CoreBundle\Controller\Product', 'app\Resources\fixtures\\', __DIR__);

    // do not change the table's orders
    $tables = array(
        // these tables used for truncate
        'product_option',
        'variant_option_value',

        // these tables used for fixtures
        'taxonomy',
        'taxon',
        'option',
        'option_value',
        'property',
        'product',
        // 'product_property',
        'product_taxon',
        'variant',
        'variant_image'
    );

    $entityManager = $this->container->get('doctrine')->getEntityManager();

    $loader = new \Nelmio\Alice\Loader\Yaml();
    $persister = new \Nelmio\Alice\ORM\Doctrine($entityManager);

    $connection = $entityManager->getConnection();
    $dbPlatform = $connection->getDatabasePlatform();
    foreach ($tables as $table) {
        $connection->beginTransaction();
        try {
            $connection->query('SET FOREIGN_KEY_CHECKS=0');
            $q = $dbPlatform->getTruncateTableSql('`' . $table . '`');
            $connection->executeUpdate($q);
            $connection->query('SET FOREIGN_KEY_CHECKS=1');
            $connection->commit();
        } catch (\Exception $e) {
            $connection->rollback();
        }

        if (file_exists($fixturePath . $table . '.yml')) {
            $objects = $loader->load($fixturePath . $table . '.yml', $entityManager);
            $persister->persist($objects);
        }
    }