Recettes : c'est bon sur l'ajout des produits, on ataque la liste des étapes
This commit is contained in:
@@ -19,12 +19,18 @@ use Thelia\Core\Event\Content\ContentUpdateEvent;
|
||||
use Thelia\Core\HttpFoundation\JsonResponse;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Model\AttributeAvI18n;
|
||||
use Thelia\Model\AttributeAvI18nQuery;
|
||||
use Thelia\Model\AttributeCombinationQuery;
|
||||
use Thelia\Model\AttributeI18n;
|
||||
use Thelia\Model\AttributeI18nQuery;
|
||||
use Thelia\Model\AttributeQuery;
|
||||
use Thelia\Model\ContentI18nQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\Map\ProductI18nTableMap;
|
||||
use Thelia\Model\Map\ProductTableMap;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Model\ProductSaleElementsQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
|
||||
@@ -37,9 +43,7 @@ class BackController extends BaseAdminController
|
||||
|
||||
public function saveRecipe(Request $request)
|
||||
{
|
||||
$error = "";
|
||||
$con = Propel::getConnection();
|
||||
$nouvelleRecette = false;
|
||||
|
||||
$form = new RecetteCreateForm($request);
|
||||
try {
|
||||
@@ -88,10 +92,40 @@ class BackController extends BaseAdminController
|
||||
{
|
||||
RecipeProductsQuery::create()->filterByRecipeId($recipeId)->filterByPseId($pseId)->delete();
|
||||
|
||||
return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/content/update/" . $contentId . "#recipe"));
|
||||
return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/content/update/" . $contentId . "?current_tab=recipe"));
|
||||
}
|
||||
|
||||
|
||||
public function getData($product_id)
|
||||
{
|
||||
$locale = $this->getCurrentEditionLocale();
|
||||
$combinations = [];
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$pse = ProductSaleElementsQuery::create()
|
||||
->filterByProductId($product_id)
|
||||
->find($con);
|
||||
|
||||
foreach ($pse as $pseItem)
|
||||
{
|
||||
$combinationsArray = AttributeCombinationQuery::create()
|
||||
->filterByProductSaleElements($pseItem)
|
||||
->find($con);
|
||||
|
||||
foreach ($combinationsArray as $combination) {
|
||||
$pseId = $pseItem->getId();
|
||||
$label = AttributeAvI18nQuery::create()
|
||||
->filterByLocale($locale)
|
||||
->findOneById($combination->getAttributeAvId())
|
||||
->getTitle();
|
||||
|
||||
array_push($combinations, [$pseId => $label]);
|
||||
}
|
||||
}
|
||||
|
||||
return $combinations;
|
||||
}
|
||||
|
||||
public function searchProduct()
|
||||
{
|
||||
$locale = $this->getCurrentEditionLocale();
|
||||
@@ -115,17 +149,13 @@ class BackController extends BaseAdminController
|
||||
|
||||
foreach ($data as $item) {
|
||||
|
||||
$combinations = AttributeCombinationQuery::create()
|
||||
->filterByProductSaleElementsId($item->getId())
|
||||
|
||||
$item
|
||||
|
||||
$combinations = self::getData($item['product.id']);
|
||||
|
||||
$result[] = [
|
||||
'id' => $item[ProductTableMap::COL_ID],
|
||||
'ref' => $item[ProductTableMap::COL_REF],
|
||||
'title' => $item['title'],
|
||||
'combinations' => []
|
||||
'combinations' => $combinations,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -133,27 +163,22 @@ class BackController extends BaseAdminController
|
||||
return JsonResponse::create($result);
|
||||
}
|
||||
|
||||
public function searchCombination()
|
||||
{
|
||||
$locale = $this->getCurrentEditionLocale();
|
||||
$ref = $this->getRequest()->get('query', null);
|
||||
$result = [];
|
||||
|
||||
return JsonResponse::create($result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public function addProduct($contentId)
|
||||
{
|
||||
$productId = (int) $this->getRequest()->get('product_id');
|
||||
$pseId = (int) $this->getRequest()->get('pse_id');
|
||||
$quantityNeeded = (string) $this->getRequest()->get('quantity_needed');
|
||||
$recipeId = (int) $this->getRequest()->get('recipe_id');
|
||||
$quantityProposed = (int) $this->getRequest()->get('quantity_proposed');
|
||||
|
||||
(new AgendaRelatedProduct())
|
||||
->setProductId($productId)
|
||||
->setContentId($contentId)
|
||||
(new RecipeProducts())
|
||||
->setRecipeId($recipeId)
|
||||
->setPseId($pseId)
|
||||
->setQuantity($quantityNeeded)
|
||||
->setNbOfProducts($quantityProposed)
|
||||
->save();
|
||||
|
||||
return $this->render('ajax/related-products', [ 'content_id' => $contentId ]);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user