Example #1
0
 }
 for ($i = 0; $i < 50; $i++) {
     $customer = new Thelia\Model\Customer();
     $customer->createOrUpdate(rand(1, 3), $faker->firstname, $faker->lastname, $faker->streetAddress, $faker->streetAddress, $faker->streetAddress, $faker->phoneNumber, $faker->phoneNumber, $faker->postcode, $faker->city, 64, $faker->email, "azerty" . $i);
     for ($j = 0; $j <= 3; $j++) {
         $address = new Thelia\Model\Address();
         $address->setLabel(getRealText(20))->setTitleId(rand(1, 3))->setFirstname($faker->firstname)->setLastname($faker->lastname)->setAddress1($faker->streetAddress)->setAddress2($faker->streetAddress)->setAddress3($faker->streetAddress)->setCellphone($faker->phoneNumber)->setPhone($faker->phoneNumber)->setZipcode($faker->postcode)->setCity($faker->city)->setCountryId(64)->setCustomer($customer)->save();
     }
 }
 echo "Creating features\n";
 //features and features_av
 $featureList = array();
 for ($i = 0; $i < 4; $i++) {
     $feature = new Thelia\Model\Feature();
     $feature->setVisible(1);
     $feature->setPosition($i);
     setI18n($feature);
     $feature->save();
     $featureId = $feature->getId();
     $featureList[$featureId] = array();
     //hardcode chance to have no av
     if ($i === 1 || $i === 3) {
         for ($j = 0; $j < rand(1, 5); $j++) {
             $featureAv = new Thelia\Model\FeatureAv();
             $featureAv->setFeature($feature);
             $featureAv->setPosition($j);
             setI18n($featureAv);
             $featureAv->save();
             $featureList[$featureId][] = $featureAv->getId();
         }
     }
Example #2
0
function createMaterials($con)
{
    echo "start creating materials feature\n";
    $feature = null;
    $features = array();
    if (($handle = fopen(THELIA_ROOT . '/setup/import/materials.csv', "r")) !== FALSE) {
        $row = 0;
        $feature = new \Thelia\Model\Feature();
        $feature->setPosition(1)->setLocale('fr_FR')->setTitle('Matière')->setLocale('en_US')->setTitle('Material');
        while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
            $row++;
            $featureAv = new \Thelia\Model\FeatureAv();
            $featureAv->setPosition($row)->setLocale('fr_FR')->setTitle($data[0])->setLocale('en_US')->setTitle($data[1]);
            //$featureAv->setFeature($feature);
            $feature->addFeatureAv($featureAv);
        }
        $feature->save($con);
        fclose($handle);
    }
    echo "materials feature created successfully\n";
    return $feature;
}