Example #1
0
 /**
  * @param Manufacturer[] $manufacturers
  * @param Category[] $categories
  * @param Image[] $images
  * @param object[] $productManufacturerBinds
  * @param object[] $productCategoryBinds
  * @param object[] $productImageBinds
  * @param object[] $productPrices
  * @param object[] $objects
  * 
  * @return Product[] 
  */
 function buildAll(array $manufacturers, array $categories, array $images, array $productManufacturerBinds, array $productCategoryBinds, array $productImageBinds, array $productPrices, array $objects)
 {
     $retval = array();
     //Задаем имена свойств, выражающих связи: поле со значением родительского элемента и поле со значением дочернего
     $categoryBindParentFieldName = getPropertyNameByNum($productCategoryBinds[0], 1);
     $categoryBindChildFieldName = getPropertyNameByNum($productCategoryBinds[0], 2);
     $manufacturerBindParentFieldName = getPropertyNameByNum($productManufacturerBinds[0], 1);
     $manufacturerBindChildFieldName = getPropertyNameByNum($productManufacturerBinds[0], 2);
     $imageBindParentFieldName = getPropertyNameByNum($productImageBinds[0], 1);
     $imageBindChildFieldName = getPropertyNameByNum($productImageBinds[0], 2);
     $priceProductIdFieldName = getPropertyNameByNum($productPrices[0], 1);
     $pricePriceFieldName = getPropertyNameByNum($productPrices[0], 3);
     foreach ($objects as $object) {
         if (property_exists($object, 'virtuemart_product_id') && property_exists($object, 'product_s_desc') && property_exists($object, 'product_desc') && property_exists($object, 'product_name')) {
             $product = new Product($object->virtuemart_product_id);
             $product->name = $object->product_name;
             $product->shortDescr = $object->product_s_desc;
             $product->fullDescr = $object->product_desc;
             //ищем объект связанной категории
             $categoryBind = findByProperty($productCategoryBinds, $categoryBindParentFieldName, $product->id);
             if ($categoryBind !== null) {
                 $product->category = findByProperty($categories, 'id', $categoryBind->{$categoryBindChildFieldName});
             } else {
                 echo NOTICE . " товар № {$product->id}: " . NO_CATEGORY . "\n";
             }
             //ищем объект связанного поставщика
             $manufacturerBind = findByProperty($productManufacturerBinds, $manufacturerBindParentFieldName, $product->id);
             if ($manufacturerBind !== null) {
                 $product->manufacturer = findByProperty($manufacturers, 'id', $manufacturerBind->{$manufacturerBindChildFieldName});
             } else {
                 echo NOTICE . " товар № {$product->id}: " . NO_MANUFACTURER . "\n";
             }
             //ищем объекты связанных картинок
             $imageBinds = findAllByProperty($productImageBinds, $imageBindParentFieldName, $product->id);
             foreach ($imageBinds as $imageBind) {
                 $product->addImage(findByProperty($images, 'id', $imageBind->{$imageBindChildFieldName}));
             }
             //задаем цену продукта
             $productPrice = findByProperty($productPrices, $priceProductIdFieldName, $product->id);
             if ($productPrice !== null) {
                 $product->price = $productPrice->{$pricePriceFieldName};
             }
         }
         /**
          * @todo что делать с полями Product::ingredients, Product::keywords, Product::sale, Product::otherSpecs ???
          */
         $retval[] = $product;
     }
     return $retval;
 }
							@foreach($data['given_answers'][$question->id] as $answer_id)
								<li>
									<?php 
$answer = findByProperty($question->answers, 'id', $answer_id);
?>
									@if($answer !== false)
										{{ $answer->text }}
									@else
										Virhe: vastausta ei löytynyt.
									@endif
								</li>
							@endforeach
						@elseif($question->type == 'CHOICE')
							<li>
								<?php 
$answer = findByProperty($question->answers, 'id', $data['given_answers'][$question->id]);
?>
								@if($answer !== false)
									{{ $answer->text }}
								@else
									Virhe: vastausta ei löytynyt.
								@endif
							</li>
						@elseif($question->type == 'MULTITEXT')
							@foreach($data['given_answers'][$question->id] as $answer)
								<li>
									{!! alt($answer, '<i>Ei vastausta</i>') !!}
								</li>
							@endforeach
						@else
							<li>{!! alt($data['given_answers'][$question->id], '<i>Ei vastausta</i>') !!}</li>
Example #3
0
function importMenuData($menuData)
{
    global $table;
    foreach ($menuData as $menuDataRow) {
        $currentMenuItem = findByProperty($table, "name", $menuDataRow['name']);
        if ($currentMenuItem == null) {
            $menuItemImportOrUpdateStatement = getMenuItemImportStatement($menuDataRow);
        } else {
            $menuItemImportOrUpdateStatement = getMenuUpdateStatement($menuDataRow);
        }
        runInsert($menuItemImportOrUpdateStatement);
    }
}