Načítání a získání dat z konfigurátoru
- jAkErCZ
- Člen | 322
Zdravím,
mám udělanou admistraci našeho konfigurátoru a mám i načítání
základních dat potřeboval bych že když kliknu na produkt tak aby se mi už
jen zobrazily věci k produktu…
Model
public function getProducts(){
return $this->database->table(self::TABLE_NAME);
}
public function getColors($configure_id){
return $this->database->table('configure_product_color')
->where('product_image_group.configure_id = ', $configure_id);
}
public function getAcess($configure_id){
return $this->database->table('configure_product_accessori')
->where('product_group.configure_id = ', $configure_id);
}
presenter:
public function renderDetail($url)
{
// Pokusí se načíst produkt s danou URL a pokud nebude nalezen, vyhodí chybu 404.
if (!($product = $this->confiProdModel->getProduct($url))) throw new BadRequestException();
$colors = $this->confiProdModel->getColors(1);
$acess = $this->confiProdModel->getAcess(1);
// Předání parametrů do šablony.
$this->template->product = $product;
$this->template->colors = $colors;
$this->template->acess = $acess;
bdump($product);
}
Sablona:
<li data-selection="colors" class="builder-step first-load">
<section class="cd-step-content">
<header>
<h1>Barva</h1>
<span class="steps-indicator">Step <b>2</b> of 4</span>
</header>
<ul class="cd-product-previews">
<li class="selected"><img
src="{$basePath}/configurator/products/{$product->configure_id}/product01_col01.jpg"
alt="Product Preview" class="product-preview"></li>
<li><img src="{$basePath}/configurator/products/{$product->configure_id}/product01_col02.jpg"
alt="Product Preview" class="product-preview"></li>
<li><img src="{$basePath}/configurator/products/{$product->configure_id}/product01_col03.jpg"
alt="Product Preview" class="product-preview"></li>
</ul>
<ul class="cd-product-customizer">
<li data-content="Bílá - $0" data-price="0" class="selected"><a data-color="white" href="#0">Bílá - $0</a>
</li>
<li data-content="Tmavě šedá - $650" data-price="650"><a data-color="grey" href="#0">Tmavě šedá - $650</a>
</li>
<li data-content="Oranžová - $750" data-price="750"><a data-color="orange" href="#0">Oranžová - $750</a>
</li>
</ul>
</section>
</li>
<li data-selection="accessories" class="builder-step first-load">
<section class="cd-step-content">
<header>
<h1>Accessories</h1>
<span class="steps-indicator">Step <b>3</b> of 4</span>
</header>
<ul class="accessories-list options-list">
<li class="js-option" data-price="1080">
<p>Test</p>
<span class="price">$1.080</span>
<div class="check"></div>
</li>
</ul>
</section>
</li>
<li data-selection="summary" class="builder-step first-load">
<section class="cd-step-content">
<header>
<h1>Summary</h1>
<span class="steps-indicator">Step <b>4</b> of 4</span>
</header>
<ul class="summary-list">
<li>
<h2>Model</h2>
<img n:for="$i = 0; $i < $product->images_count; $i++"
src="{$basePath}/configurator/products/{$product->configure_id}/{$product->configure_id}_{$i}.jpg"
alt="{$product->title}" class="product-preview">
<h3>{$product->title}</h3>
<p>
{$product->short_description}
</p>
</li>
<li data-summary="colors">
<h2>Color</h2>
<span class="summary-color">
<em class="color-swatch" data-color="red"></em>
<em class="color-label">Red Passion</em>
</span>
</li>
<li data-summary="accessories">
<h2>Accessories</h2>
<ul class="summary-accessories">
<li>
<p>Uconnect 6.5" colour touchscreen radio navigation sytem with Bluetooth & DAB ($1050)</p>
</li>
<li>
<p>Audio & telephone controls on steering wheels ($750)</p>
</li>
</ul>
</li>
</ul>
</section>
</li>
Potřeboval bych nějak dosadit třeba ID toho produktu aby mi to vrátily ty funkce jako barevnost, doplnky
DUMP – $product
Nette\Database\Table\ActiveRow #85dc
table private => Nette\Database\Table\Selection #0a9e
data private => array (8)
configure_id => 1
code => "159753" (6)
url => "perito" (6)
title => "Perito" (6)
short_description => "<p>Nejlepší dveře na světě</p>" (35)
price => 14200.0
images_count => 1
hidden => 0
dataRefreshed private => false
potřeboval bych nějak to configure_id dostat do $this->confiProdModel->getColors(1);
Nějaký nápad?
Díky
Editoval jAkErCZ (17. 4. 2018 15:28)