src/Controller/ProduitsController.php line 844
<?php
namespace App\Controller;
use App\Services\DbProduct;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class ProduitsController extends AbstractController
{
#[Route(
path: ['fr' => '/{_locale}/capteurs-de-force', 'en' => '/{_locale}/load-cells'],
name: 'capteurs_force',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function capteurs_force(Request $request, DbProduct $dbProduct): Response
{
if ($request->getLocale() == 'fr') {
$link = '/en/load-cells';
$lienDb = "capteurs-de-force";
} else {
$link = '/fr/capteurs-de-force';
$lienDb = "load-cells";
}
$contents = $dbProduct->getContent($lienDb, $request->getLocale());
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$category = $contents[0]["id_category"];
$products = $dbProduct->getProducts($request->getLocale(), $category);
$filters = $dbProduct->getAllAttrCategories($request->getLocale(), $category);
$filtersFeat = $dbProduct->getAllFeatCategories($request->getLocale(), $category);
return $this->render('produit/produits.html.twig', ['contents' => $contents, 'link' => $link, 'breadcrumb' => '', 'products' => $products, 'categories' => $filters, 'features' => $filtersFeat]);
}
#[Route(
path: ['fr' => '/{_locale}/capteurs-de-pesage', 'en' => '/{_locale}/weighing-load-cells'],
name: 'capteurs_pesage',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function capteurs_pesage(Request $request, DbProduct $dbProduct): Response
{
if ($request->getLocale() == 'fr') {
$link = '/en/weighing-load-cells';
$lienDb = "capteurs-de-pesage";
} else {
$link = '/fr/capteurs-de-pesage';
$lienDb = "weighing-load-cells";
}
$contents = $dbProduct->getContent($lienDb, $request->getLocale());
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$category = $contents[0]["id_category"];
$products = $dbProduct->getProducts($request->getLocale(), $category);
$filters = $dbProduct->getAllAttrCategories($request->getLocale(), $category);
$filtersFeat = $dbProduct->getAllFeatCategories($request->getLocale(), $category);
return $this->render('produit/produits.html.twig', ['contents' => $contents, 'link' => $link, 'breadcrumb' => "", 'products' => $products, 'categories' => $filters, 'features' => $filtersFeat]);
}
#[Route(
path: ['fr' => '/{_locale}/capteurs-de-force-etalon', 'en' => '/{_locale}/reference-force-transducers'],
name: 'capteurs_force_etalon',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function capteurs_force_etalon(Request $request, DbProduct $dbProduct): Response
{
if ($request->getLocale() == 'fr') {
$link = '/en/reference-force-transducers';
$lienDb = "capteurs-de-force-etalon";
} else {
$link = '/fr/capteurs-de-force-etalon';
$lienDb = "reference-force-transducers";
}
$contents = $dbProduct->getContent($lienDb, $request->getLocale());
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$category = $contents[0]["id_category"];
$products = $dbProduct->getProducts($request->getLocale(), $category);
$filters = $dbProduct->getAllAttrCategories($request->getLocale(), $category);
$filtersFeat = $dbProduct->getAllFeatCategories($request->getLocale(), $category);
return $this->render('produit/produits.html.twig', ['contents' => $contents, 'link' => $link, 'breadcrumb' => "", 'products' => $products, 'categories' => $filters, 'features' => $filtersFeat]);
}
#[Route(
path: ['fr' => '/{_locale}/limitation-de-charge', 'en' => '/{_locale}/crane-overload-protection'],
name: 'limitation_charge',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function limitation_charge(Request $request, DbProduct $dbProduct): Response
{
if ($request->getLocale() == 'fr') {
$link = '/en/crane-overload-protection';
$lienDb = "limitation-de-charge";
} else {
$link = '/fr/limitation-de-charge';
$lienDb = "crane-overload-protection";
}
$contents = $dbProduct->getContent($lienDb, $request->getLocale());
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$category = $contents[0]["id_category"];
$products = $dbProduct->getProducts($request->getLocale(), $category);
$filters = $dbProduct->getAllAttrCategories($request->getLocale(), $category);
$filtersFeat = $dbProduct->getAllFeatCategories($request->getLocale(), $category);
return $this->render('produit/produits.html.twig', ['contents' => $contents, 'link' => $link, 'breadcrumb' => "", 'products' => $products, 'categories' => $filters, 'features' => $filtersFeat]);
}
#[Route(
path: ['fr' => '/{_locale}/capteurs-de-couple', 'en' => '/{_locale}/torque-transducers'],
name: 'capteurs_couple',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function capteurs_couple(Request $request, DbProduct $dbProduct): Response
{
if ($request->getLocale() == 'fr') {
$link = '/en/torque-transducers';
$lienDb = "capteurs-de-couple";
} else {
$link = '/fr/capteurs-de-couple';
$lienDb = "torque-transducers";
}
$contents = $dbProduct->getContent($lienDb, $request->getLocale());
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$category = $contents[0]["id_category"];
$products = $dbProduct->getProducts($request->getLocale(), $category);
$filters = $dbProduct->getAllAttrCategories($request->getLocale(), $category);
$filtersFeat = $dbProduct->getAllFeatCategories($request->getLocale(), $category);
return $this->render('produit/produits.html.twig', ['contents' => $contents, 'link' => $link, 'breadcrumb' => "", 'products' => $products, 'categories' => $filters, 'features' => $filtersFeat]);
}
#[Route(
path: ['fr' => '/{_locale}/tensiometres', 'en' => '/{_locale}/tensiometers'],
name: 'tensiometres',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function tensiometres(Request $request, DbProduct $dbProduct): Response
{
if ($request->getLocale() == 'fr') {
$link = '/en/tensiometers';
$lienDb = "tensiometres";
} else {
$link = '/fr/tensiometres';
$lienDb = "tensiometers";
}
$contents = $dbProduct->getContent($lienDb, $request->getLocale());
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$category = $contents[0]["id_category"];
$products = $dbProduct->getProducts($request->getLocale(), $category);
$filters = $dbProduct->getAllAttrCategories($request->getLocale(), $category);
$filtersFeat = $dbProduct->getAllFeatCategories($request->getLocale(), $category);
return $this->render('produit/produits.html.twig', ['contents' => $contents, 'link' => $link, 'breadcrumb' => "", 'products' => $products, 'categories' => $filters, 'features' => $filtersFeat]);
}
#[Route(
path: ['fr' => '/{_locale}/instrumentation', 'en' => '/{_locale}/instrumentation'],
name: 'instrumentation',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function instrumentation(Request $request, DbProduct $dbProduct): Response
{
if ($request->getLocale() == 'fr') {
$link = '/en/instrumentation';
$lienDb = "instrumentation";
} else {
$link = '/fr/instrumentation';
$lienDb = "instrumentation";
}
$contents = $dbProduct->getContent($lienDb, $request->getLocale());
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$category = $contents[0]["id_category"];
$products = $dbProduct->getProducts($request->getLocale(), $category);
return $this->render('produit/produits.html.twig', ['contents' => $contents, 'link' => $link, 'breadcrumb' => "", 'products' => $products, "instrumentation" => true]);
}
#[Route(
path: ['fr' => '/{_locale}/capteurs-de-force/{link}', 'en' => '/{_locale}/load-cells/{link}'],
name: 'capteurs_force_produit',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function capteurs_force_produit(Request $request, DbProduct $dbProduct, EntityManagerInterface $entityManager, $link = null): Response
{
if ($request->getLocale() == 'fr') {
$breadcrumb = array(['name' => 'Capteurs de pesage', 'link_rewrite' => 'capteurs-de-force']);
} else {
$breadcrumb = array(['name' => 'Load cells', 'link_rewrite' => 'load-cells']);
}
$contents = $dbProduct->getProduct($request->getLocale(), $link);
$linkrewrite = $dbProduct->getLink($contents[0]['id_product'], $request);
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$productsElectro = $dbProduct->getProductsElectro($request->getLocale(), $contents[0]["category_default"]);
$Langue = $request->getLocale() == "fr" ? "1" : "2";
$id_product = $contents[0]["id_product"];
$myproduct = $contents[0];
$categories = [$myproduct["category_default"]];
if (in_array(18, $categories)) {
$AttributGroupe = 6; //instrumentation => ref article
} else {
$AttributGroupe = 5; // capteur => precision
}
$sql = "
SELECT fp.id_feature, fp.id_product , fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.id_product = $id_product ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$SQLArrayFeaturedProduitEnCours = $query->executeQuery()->fetchAllAssociative();
foreach ($SQLArrayFeaturedProduitEnCours as $cle => $infos) {
$ArrayFeaturedProduitEnCours[] = $infos['id_feature'];
}
$tmpattributes = $myproduct["attr_cap"] . "," . $myproduct["attr_prec"];
$tmpattributesid = $myproduct["attr_cap_id"] . "," . $myproduct["attr_prec_id"];
$attributes = [];
foreach (explode(",", $tmpattributes) as $k => $attr) {
$attributes[$k]['id_attribute_group'] = explode(",", $tmpattributesid)[$k];
$attributes[$k]['attribute_name'] = $attr;
}
$attrCap = explode(",", $myproduct["attr_cap"]);
$attrCap = array_reverse($attrCap);
$attrCap = implode(',', $attrCap);
$attrCapId = explode(',', $myproduct["attr_cap_id"]);
$attrCapId = array_reverse($attrCapId);
$attrCapId = implode(',', $attrCapId);
$attrPrec = explode(',', $myproduct["attr_prec"]);
$attrPrec = array_reverse($attrPrec);
$attrPrec = implode($attrPrec);
$attrPrecid = explode(',', $myproduct["attr_prec_id"]);
$attrPrecid = array_reverse($attrPrecid);
$attrPrecid = implode(',', $attrPrecid);
$attributes2 = array();
foreach ($attributes as $cle => $attribute) {
//id precison ou ref article => 6
if ($attribute['id_attribute_group'] == $AttributGroupe) {
if (substr($attribute['attribute_name'], -1, 1) == ' ') {
$attribute['attribute_name'] = substr($attribute['attribute_name'], 0, -1);
}
$attributes2[$attribute['group_name']]['list'][$attribute['attribute_name']] = $attribute['attribute_name'];
}
}
$reference = $myproduct['reference'];
// on va chercher les caracteristiques des produits dont la reference commence par $reference (exemple : 5000)
$sql = "
SELECT fp.id_feature, fp.id_product, fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.reference LIKE '" . $reference . "\_%' ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$Array = $query->executeQuery()->fetchAllAssociative();
$ArrayCaracteristiques = array();
foreach ($Array as $cle => $infos) {
$PageName = $infos['name'];
$sqlPagesCms = '
SELECT cl.link_rewrite,cl.meta_title,cl.meta_description,cl.id_cms,c.active,ccl.link_rewrite as link2, ccl2.link_rewrite as link1
FROM `pre2398_cms` c
INNER JOIN `pre2398_cms_lang` cl ON cl.id_cms = c.id_cms
INNER JOIN `pre2398_cms_category` cc ON cc.id_cms_category = c.id_cms_category
INNER JOIN `pre2398_cms_category_lang` ccl ON ccl.id_cms_category = cc.id_cms_category
INNER JOIN `pre2398_cms_category` cc2 ON cc2.id_cms_category = cc.id_parent
INNER JOIN `pre2398_cms_category_lang` ccl2 ON ccl2.id_cms_category = cc2.id_cms_category
WHERE cl.id_lang = ' . $Langue . '
AND cl.meta_title = "' . $PageName . '"
';
$query = $entityManager->getConnection()->prepare($sqlPagesCms);
$PageCms = $query->executeQuery()->fetchAllAssociative();
if ($PageCms != array()) {
if ($PageCms[0]['id_cms']) {
$meta_description = $PageCms[0]['meta_description'];
if ($PageCms[0]['active']) {
$url = "";
$url .= $PageCms[0]["link1"] ? "/" . $PageCms[0]["link1"] : "";
$url .= $PageCms[0]["link2"] ? "/" . $PageCms[0]["link2"] : "";
$url .= $PageCms[0]["link_rewrite"] ? "/" . $PageCms[0]["link_rewrite"] : "";
} else {
$url = "";
}
} else {
$meta_description = '';
$url = '';
}
} else {
$meta_description = '';
$url = '';
}
$ref = explode('_', $infos['reference']);
// on ne garde que les caracteristiques qui concernent le produit en cours
if (in_array($infos['id_feature'], $ArrayFeaturedProduitEnCours)) {
$ArrayCaracteristiques[$infos['id_feature']]['FeatureName'] = $infos['name'];
$ArrayCaracteristiques[$infos['id_feature']]['url'] = $url;
$ArrayCaracteristiques[$infos['id_feature']]['meta_description'] = $meta_description;
$infos['value'] = str_replace('[PPQ]', '<', $infos['value']);
$infos['value'] = str_replace('[PGQ]', '>', $infos['value']);
$infos['value'] = str_replace('[EG]', '=', $infos['value']);
$ArrayCaracteristiques[$infos['id_feature']]['Products'][$ref[2]] = array(
'cle' => $ref[2],
'reference' => $infos['reference'],
'value' => $infos['value'],
'nom' => $ref[1]
);
}
}
//cette partie permet de trier le tableau suivant les references des articles/caracteristiques grace a la cle puis on remet la cle/nom qui permettra l'affichage
$ArrayCaracteristiques2 = $ArrayCaracteristiques;
foreach ($ArrayCaracteristiques as $id => $donnees) {
ksort($donnees['Products']);
$ArrayCaracteristiques2[$id]['Products'] = [];
foreach ($donnees['Products'] as $id2 => $donnees2) {
$ArrayCaracteristiques2[$id]['Products'][$donnees2['nom']] = $donnees2;
}
}
// cette partie permet de trier les caracteristiques
$i = 0;
$TabCarac = [];
foreach ($ArrayCaracteristiques2 as $id => $donnees) {
if ($i == 0) {
foreach ($donnees['Products'] as $id2 => $donnees2) {
$TabCarac[$donnees2['nom']] = $donnees2['nom'];
$i++;
}
}
}
$files = $dbProduct->getProductAttachment($request->getLocale(), $myproduct['id_product']);
$accessories = $dbProduct->getProductAccessories($request->getLocale(), $myproduct['id_product']);
$appProduct = [];
foreach ($accessories as $accessory) {
if ($accessory['name'] == 'Applications') {
$debut = strpos($accessory['content'], '{products}');
$fin = strpos($accessory['content'], '{/products}');
$references = substr($accessory['content'], $debut + strlen('{products}'), $fin - $debut - strlen('{products}'));
foreach (explode(",", $references) as $reference) {
array_push($appProduct, $dbProduct->getProductReference($request->getLocale(), $reference)[0]);
}
}
}
return $this->render('produit/produit.html.twig', ['contents' => $contents, 'link' => $linkrewrite, 'breadcrumb' => $breadcrumb, 'productsElectro' => $productsElectro, 'caracteristiques' => $ArrayCaracteristiques2, 'files' => $files, 'accessories' => $accessories, 'appProduct' => $appProduct]);
}
#[Route(
path: ['fr' => '/{_locale}/capteurs-de-pesage/{link}', 'en' => '/{_locale}/weighing-load-cells/{link}'],
name: 'capteur_pesage_produit',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function capteur_pesage_produit(Request $request, DbProduct $dbProduct, EntityManagerInterface $entityManager, $link = null): Response
{
if ($request->getLocale() == 'fr') {
$breadcrumb = array(['name' => 'Capteurs de pesage', 'link_rewrite' => 'capteurs-de-pesage']);
} else {
$breadcrumb = array(['name' => 'Weighing load cells', 'link_rewrite' => 'weighing-load-cells']);
}
$contents = $dbProduct->getProduct($request->getLocale(), $link);
$linkrewrite = $dbProduct->getLink($contents[0]['id_product'], $request);
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$productsElectro = $dbProduct->getProductsElectro($request->getLocale(), $contents[0]["category_default"]);
$Langue = $request->getLocale() == "fr" ? "1" : "2";
$id_product = $contents[0]["id_product"];
$myproduct = $contents[0];
$categories = [$myproduct["category_default"]];
if (in_array(18, $categories)) {
$AttributGroupe = 6; //instrumentation => ref article
} else {
$AttributGroupe = 5; // capteur => precision
}
$sql = "
SELECT fp.id_feature, fp.id_product , fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.id_product = $id_product ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$SQLArrayFeaturedProduitEnCours = $query->executeQuery()->fetchAllAssociative();
foreach ($SQLArrayFeaturedProduitEnCours as $cle => $infos) {
$ArrayFeaturedProduitEnCours[] = $infos['id_feature'];
}
$tmpattributes = $myproduct["attr_cap"] . "," . $myproduct["attr_prec"];
$tmpattributesid = $myproduct["attr_cap_id"] . "," . $myproduct["attr_prec_id"];
$attributes = [];
foreach (explode(",", $tmpattributes) as $k => $attr) {
$attributes[$k]['id_attribute_group'] = explode(",", $tmpattributesid)[$k];
$attributes[$k]['attribute_name'] = $attr;
}
$attributes2 = array();
foreach ($attributes as $cle => $attribute) {
//id precison ou ref article => 6
if ($attribute['id_attribute_group'] == $AttributGroupe) {
if (substr($attribute['attribute_name'], -1, 1) == ' ') {
$attribute['attribute_name'] = substr($attribute['attribute_name'], 0, -1);
}
$attributes2[$attribute['group_name']]['list'][$attribute['attribute_name']] = $attribute['attribute_name'];
}
}
$reference = $myproduct['reference'];
// on va chercher les caracteristiques des produits dont la reference commence par $reference (exemple : 5000)
$sql = "
SELECT fp.id_feature, fp.id_product, fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.reference LIKE '" . $reference . "\_%' ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$Array = $query->executeQuery()->fetchAllAssociative();
$ArrayCaracteristiques = array();
foreach ($Array as $cle => $infos) {
$PageName = $infos['name'];
$sqlPagesCms = '
SELECT cl.link_rewrite,cl.meta_title,cl.meta_description,cl.id_cms,c.active,ccl.link_rewrite as link2, ccl2.link_rewrite as link1
FROM `pre2398_cms` c
INNER JOIN `pre2398_cms_lang` cl ON cl.id_cms = c.id_cms
INNER JOIN `pre2398_cms_category` cc ON cc.id_cms_category = c.id_cms_category
INNER JOIN `pre2398_cms_category_lang` ccl ON ccl.id_cms_category = cc.id_cms_category
INNER JOIN `pre2398_cms_category` cc2 ON cc2.id_cms_category = cc.id_parent
INNER JOIN `pre2398_cms_category_lang` ccl2 ON ccl2.id_cms_category = cc2.id_cms_category
WHERE cl.id_lang = ' . $Langue . '
AND cl.meta_title = "' . $PageName . '"
';
$query = $entityManager->getConnection()->prepare($sqlPagesCms);
$PageCms = $query->executeQuery()->fetchAllAssociative();
if ($PageCms != array()) {
if ($PageCms[0]['id_cms']) {
$meta_description = $PageCms[0]['meta_description'];
if ($PageCms[0]['active']) {
$url = "";
$url .= $PageCms[0]["link1"] ? "/" . $PageCms[0]["link1"] : "";
$url .= $PageCms[0]["link2"] ? "/" . $PageCms[0]["link2"] : "";
$url .= $PageCms[0]["link_rewrite"] ? "/" . $PageCms[0]["link_rewrite"] : "";
} else {
$url = "";
}
} else {
$meta_description = '';
$url = '';
}
} else {
$meta_description = '';
$url = '';
}
$ref = explode('_', $infos['reference']);
// on ne garde que les caracteristiques qui concernent le produit en cours
if (in_array($infos['id_feature'], $ArrayFeaturedProduitEnCours)) {
$ArrayCaracteristiques[$infos['id_feature']]['FeatureName'] = $infos['name'];
$ArrayCaracteristiques[$infos['id_feature']]['url'] = $url;
$ArrayCaracteristiques[$infos['id_feature']]['meta_description'] = $meta_description;
$infos['value'] = str_replace('[PPQ]', '<', $infos['value']);
$infos['value'] = str_replace('[PGQ]', '>', $infos['value']);
$infos['value'] = str_replace('[EG]', '=', $infos['value']);
$ArrayCaracteristiques[$infos['id_feature']]['Products'][$ref[2]] = array(
'cle' => $ref[2],
'reference' => $infos['reference'],
'value' => $infos['value'],
'nom' => $ref[1]
);
}
}
//cette partie permet de trier le tableau suivant les references des articles/caracteristiques grace a la cle puis on remet la cle/nom qui permettra l'affichage
$ArrayCaracteristiques2 = $ArrayCaracteristiques;
foreach ($ArrayCaracteristiques as $id => $donnees) {
ksort($donnees['Products']);
$ArrayCaracteristiques2[$id]['Products'] = [];
foreach ($donnees['Products'] as $id2 => $donnees2) {
$ArrayCaracteristiques2[$id]['Products'][$donnees2['nom']] = $donnees2;
}
}
// cette partie permet de trier les caracteristiques
$i = 0;
$TabCarac = [];
foreach ($ArrayCaracteristiques2 as $id => $donnees) {
if ($i == 0) {
foreach ($donnees['Products'] as $id2 => $donnees2) {
$TabCarac[$donnees2['nom']] = $donnees2['nom'];
$i++;
}
}
}
$files = $dbProduct->getProductAttachment($request->getLocale(), $myproduct['id_product']);
$accessories = $dbProduct->getProductAccessories($request->getLocale(), $myproduct['id_product']);
$appProduct = [];
foreach ($accessories as $accessory) {
if ($accessory['name'] == 'Applications') {
$debut = strpos($accessory['content'], '{products}');
$fin = strpos($accessory['content'], '{/products}');
$references = substr($accessory['content'], $debut + strlen('{products}'), $fin - $debut - strlen('{products}'));
foreach (explode(",", $references) as $reference) {
array_push($appProduct, $dbProduct->getProductReference($request->getLocale(), $reference)[0]);
}
}
}
return $this->render('produit/produit.html.twig', ['contents' => $contents, 'link' => $linkrewrite, 'breadcrumb' => $breadcrumb, 'productsElectro' => $productsElectro, 'caracteristiques' => $ArrayCaracteristiques2, 'files' => $files, 'accessories' => $accessories, 'appProduct' => $appProduct]);
}
#[Route(
path: ['fr' => '/{_locale}/capteurs-de-force-etalon/{link}', 'en' => '/{_locale}/reference-force-transducers/{link}'],
name: 'capteurs_force_etalon_produit',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function capteurs_force_etalon_produit(Request $request, DbProduct $dbProduct, EntityManagerInterface $entityManager, $link = null): Response
{
if ($request->getLocale() == 'fr') {
$breadcrumb = array(['name' => 'Capteurs de force étalon', 'link_rewrite' => 'capteurs-de-force-etalon']);
} else {
$breadcrumb = array(['name' => 'Reference force transducers', 'link_rewrite' => 'reference-force-transducers']);
}
$contents = $dbProduct->getProduct($request->getLocale(), $link);
$linkrewrite = $dbProduct->getLink($contents[0]['id_product'], $request);
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$productsElectro = $dbProduct->getProductsElectro($request->getLocale(), $contents[0]["category_default"]);
$Langue = $request->getLocale() == "fr" ? "1" : "2";
$id_product = $contents[0]["id_product"];
$myproduct = $contents[0];
$categories = [$myproduct["category_default"]];
if (in_array(18, $categories)) {
$AttributGroupe = 6; //instrumentation => ref article
} else {
$AttributGroupe = 5; // capteur => precision
}
$sql = "
SELECT fp.id_feature, fp.id_product , fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.id_product = $id_product ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$SQLArrayFeaturedProduitEnCours = $query->executeQuery()->fetchAllAssociative();
foreach ($SQLArrayFeaturedProduitEnCours as $cle => $infos) {
$ArrayFeaturedProduitEnCours[] = $infos['id_feature'];
}
$tmpattributes = $myproduct["attr_cap"] . "," . $myproduct["attr_prec"];
$tmpattributesid = $myproduct["attr_cap_id"] . "," . $myproduct["attr_prec_id"];
$attributes = [];
foreach (explode(",", $tmpattributes) as $k => $attr) {
$attributes[$k]['id_attribute_group'] = explode(",", $tmpattributesid)[$k];
$attributes[$k]['attribute_name'] = $attr;
}
$attributes2 = array();
foreach ($attributes as $cle => $attribute) {
//id precison ou ref article => 6
if ($attribute['id_attribute_group'] == $AttributGroupe) {
if (substr($attribute['attribute_name'], -1, 1) == ' ') {
$attribute['attribute_name'] = substr($attribute['attribute_name'], 0, -1);
}
$attributes2[$attribute['group_name']]['list'][$attribute['attribute_name']] = $attribute['attribute_name'];
}
}
$reference = $myproduct['reference'];
// on va chercher les caracteristiques des produits dont la reference commence par $reference (exemple : 5000)
$sql = "
SELECT fp.id_feature, fp.id_product, fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.reference LIKE '" . $reference . "\_%' ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$Array = $query->executeQuery()->fetchAllAssociative();
$ArrayCaracteristiques = array();
foreach ($Array as $cle => $infos) {
$PageName = $infos['name'];
$sqlPagesCms = '
SELECT cl.link_rewrite,cl.meta_title,cl.meta_description,cl.id_cms,c.active,ccl.link_rewrite as link2, ccl2.link_rewrite as link1
FROM `pre2398_cms` c
INNER JOIN `pre2398_cms_lang` cl ON cl.id_cms = c.id_cms
INNER JOIN `pre2398_cms_category` cc ON cc.id_cms_category = c.id_cms_category
INNER JOIN `pre2398_cms_category_lang` ccl ON ccl.id_cms_category = cc.id_cms_category
INNER JOIN `pre2398_cms_category` cc2 ON cc2.id_cms_category = cc.id_parent
INNER JOIN `pre2398_cms_category_lang` ccl2 ON ccl2.id_cms_category = cc2.id_cms_category
WHERE cl.id_lang = ' . $Langue . '
AND cl.meta_title = "' . $PageName . '"
';
$query = $entityManager->getConnection()->prepare($sqlPagesCms);
$PageCms = $query->executeQuery()->fetchAllAssociative();
if ($PageCms != array()) {
if ($PageCms[0]['id_cms']) {
$meta_description = $PageCms[0]['meta_description'];
if ($PageCms[0]['active']) {
$url = "";
$url .= $PageCms[0]["link1"] ? "/" . $PageCms[0]["link1"] : "";
$url .= $PageCms[0]["link2"] ? "/" . $PageCms[0]["link2"] : "";
$url .= $PageCms[0]["link_rewrite"] ? "/" . $PageCms[0]["link_rewrite"] : "";
} else {
$url = "";
}
} else {
$meta_description = '';
$url = '';
}
} else {
$meta_description = '';
$url = '';
}
$ref = explode('_', $infos['reference']);
// on ne garde que les caracteristiques qui concernent le produit en cours
if (in_array($infos['id_feature'], $ArrayFeaturedProduitEnCours)) {
$ArrayCaracteristiques[$infos['id_feature']]['FeatureName'] = $infos['name'];
$ArrayCaracteristiques[$infos['id_feature']]['url'] = $url;
$ArrayCaracteristiques[$infos['id_feature']]['meta_description'] = $meta_description;
$infos['value'] = str_replace('[PPQ]', '<', $infos['value']);
$infos['value'] = str_replace('[PGQ]', '>', $infos['value']);
$infos['value'] = str_replace('[EG]', '=', $infos['value']);
$ArrayCaracteristiques[$infos['id_feature']]['Products'][$ref[2]] = array(
'cle' => $ref[2],
'reference' => $infos['reference'],
'value' => $infos['value'],
'nom' => $ref[1]
);
}
}
//cette partie permet de trier le tableau suivant les references des articles/caracteristiques grace a la cle puis on remet la cle/nom qui permettra l'affichage
$ArrayCaracteristiques2 = $ArrayCaracteristiques;
foreach ($ArrayCaracteristiques as $id => $donnees) {
ksort($donnees['Products']);
$ArrayCaracteristiques2[$id]['Products'] = [];
foreach ($donnees['Products'] as $id2 => $donnees2) {
$ArrayCaracteristiques2[$id]['Products'][$donnees2['nom']] = $donnees2;
}
}
// cette partie permet de trier les caracteristiques
$i = 0;
$TabCarac = [];
foreach ($ArrayCaracteristiques2 as $id => $donnees) {
if ($i == 0) {
foreach ($donnees['Products'] as $id2 => $donnees2) {
$TabCarac[$donnees2['nom']] = $donnees2['nom'];
$i++;
}
}
}
$files = $dbProduct->getProductAttachment($request->getLocale(), $myproduct['id_product']);
$accessories = $dbProduct->getProductAccessories($request->getLocale(), $myproduct['id_product']);
$appProduct = [];
foreach ($accessories as $accessory) {
if ($accessory['name'] == 'Applications') {
$debut = strpos($accessory['content'], '{products}');
$fin = strpos($accessory['content'], '{/products}');
$references = substr($accessory['content'], $debut + strlen('{products}'), $fin - $debut - strlen('{products}'));
foreach (explode(",", $references) as $reference) {
array_push($appProduct, $dbProduct->getProductReference($request->getLocale(), $reference)[0]);
}
}
}
return $this->render('produit/produit.html.twig', ['contents' => $contents, 'link' => $linkrewrite, 'breadcrumb' => $breadcrumb, 'productsElectro' => $productsElectro, 'caracteristiques' => $ArrayCaracteristiques2, 'files' => $files, 'accessories' => $accessories, 'appProduct' => $appProduct]);
}
#[Route(
path: ['fr' => '/{_locale}/limitation-de-charge/{link}', 'en' => '/{_locale}/crane-overload-protection/{link}'],
name: 'limitation_charge_produit',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function limitation_charge_produit(Request $request, DbProduct $dbProduct, EntityManagerInterface $entityManager, $link = null): Response
{
if ($request->getLocale() == 'fr') {
$breadcrumb = array(['name' => 'Limitation de charge', 'link_rewrite' => 'limitation-de-charge']);
} else {
$breadcrumb = array(['name' => 'Crane overload protection', 'link_rewrite' => 'crane-overload-protection']);
}
$contents = $dbProduct->getProduct($request->getLocale(), $link);
$linkrewrite = $dbProduct->getLink($contents[0]['id_product'], $request);
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$productsElectro = $dbProduct->getProductsElectro($request->getLocale(), $contents[0]["category_default"]);
$Langue = $request->getLocale() == "fr" ? "1" : "2";
$id_product = $contents[0]["id_product"];
$myproduct = $contents[0];
$categories = [$myproduct["category_default"]];
if (in_array(18, $categories)) {
$AttributGroupe = 6; //instrumentation => ref article
} else {
$AttributGroupe = 5; // capteur => precision
}
$sql = "
SELECT fp.id_feature, fp.id_product , fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.id_product = $id_product ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$SQLArrayFeaturedProduitEnCours = $query->executeQuery()->fetchAllAssociative();
foreach ($SQLArrayFeaturedProduitEnCours as $cle => $infos) {
$ArrayFeaturedProduitEnCours[] = $infos['id_feature'];
}
$tmpattributes = $myproduct["attr_cap"] . "," . $myproduct["attr_prec"];
$tmpattributesid = $myproduct["attr_cap_id"] . "," . $myproduct["attr_prec_id"];
$attributes = [];
foreach (explode(",", $tmpattributes) as $k => $attr) {
$attributes[$k]['id_attribute_group'] = explode(",", $tmpattributesid)[$k];
$attributes[$k]['attribute_name'] = $attr;
}
$attributes2 = array();
foreach ($attributes as $cle => $attribute) {
//id precison ou ref article => 6
if ($attribute['id_attribute_group'] == $AttributGroupe) {
if (substr($attribute['attribute_name'], -1, 1) == ' ') {
$attribute['attribute_name'] = substr($attribute['attribute_name'], 0, -1);
}
$attributes2[$attribute['group_name']]['list'][$attribute['attribute_name']] = $attribute['attribute_name'];
}
}
$reference = $myproduct['reference'];
// on va chercher les caracteristiques des produits dont la reference commence par $reference (exemple : 5000)
$sql = "
SELECT fp.id_feature, fp.id_product, fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.reference LIKE '" . $reference . "\_%' ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$Array = $query->executeQuery()->fetchAllAssociative();
$ArrayCaracteristiques = array();
foreach ($Array as $cle => $infos) {
$PageName = $infos['name'];
$sqlPagesCms = '
SELECT cl.link_rewrite,cl.meta_title,cl.meta_description,cl.id_cms,c.active,ccl.link_rewrite as link2, ccl2.link_rewrite as link1
FROM `pre2398_cms` c
INNER JOIN `pre2398_cms_lang` cl ON cl.id_cms = c.id_cms
INNER JOIN `pre2398_cms_category` cc ON cc.id_cms_category = c.id_cms_category
INNER JOIN `pre2398_cms_category_lang` ccl ON ccl.id_cms_category = cc.id_cms_category
INNER JOIN `pre2398_cms_category` cc2 ON cc2.id_cms_category = cc.id_parent
INNER JOIN `pre2398_cms_category_lang` ccl2 ON ccl2.id_cms_category = cc2.id_cms_category
WHERE cl.id_lang = ' . $Langue . '
AND cl.meta_title = "' . $PageName . '"
';
$query = $entityManager->getConnection()->prepare($sqlPagesCms);
$PageCms = $query->executeQuery()->fetchAllAssociative();
if ($PageCms != array()) {
if ($PageCms[0]['id_cms']) {
$meta_description = $PageCms[0]['meta_description'];
if ($PageCms[0]['active']) {
$url = "";
$url .= $PageCms[0]["link1"] ? "/" . $PageCms[0]["link1"] : "";
$url .= $PageCms[0]["link2"] ? "/" . $PageCms[0]["link2"] : "";
$url .= $PageCms[0]["link_rewrite"] ? "/" . $PageCms[0]["link_rewrite"] : "";
} else {
$url = "";
}
} else {
$meta_description = '';
$url = '';
}
} else {
$meta_description = '';
$url = '';
}
$ref = explode('_', $infos['reference']);
// on ne garde que les caracteristiques qui concernent le produit en cours
if (in_array($infos['id_feature'], $ArrayFeaturedProduitEnCours)) {
$ArrayCaracteristiques[$infos['id_feature']]['FeatureName'] = $infos['name'];
$ArrayCaracteristiques[$infos['id_feature']]['url'] = $url;
$ArrayCaracteristiques[$infos['id_feature']]['meta_description'] = $meta_description;
$infos['value'] = str_replace('[PPQ]', '<', $infos['value']);
$infos['value'] = str_replace('[PGQ]', '>', $infos['value']);
$infos['value'] = str_replace('[EG]', '=', $infos['value']);
$ArrayCaracteristiques[$infos['id_feature']]['Products'][$ref[2]] = array(
'cle' => $ref[2],
'reference' => $infos['reference'],
'value' => $infos['value'],
'nom' => $ref[1]
);
}
}
//cette partie permet de trier le tableau suivant les references des articles/caracteristiques grace a la cle puis on remet la cle/nom qui permettra l'affichage
$ArrayCaracteristiques2 = $ArrayCaracteristiques;
foreach ($ArrayCaracteristiques as $id => $donnees) {
ksort($donnees['Products']);
$ArrayCaracteristiques2[$id]['Products'] = [];
foreach ($donnees['Products'] as $id2 => $donnees2) {
$ArrayCaracteristiques2[$id]['Products'][$donnees2['nom']] = $donnees2;
}
}
// cette partie permet de trier les caracteristiques
$i = 0;
$TabCarac = [];
foreach ($ArrayCaracteristiques2 as $id => $donnees) {
if ($i == 0) {
foreach ($donnees['Products'] as $id2 => $donnees2) {
$TabCarac[$donnees2['nom']] = $donnees2['nom'];
$i++;
}
}
}
$files = $dbProduct->getProductAttachment($request->getLocale(), $myproduct['id_product']);
$accessories = $dbProduct->getProductAccessories($request->getLocale(), $myproduct['id_product']);
$appProduct = [];
foreach ($accessories as $accessory) {
if ($accessory['name'] == 'Applications') {
$debut = strpos($accessory['content'], '{products}');
$fin = strpos($accessory['content'], '{/products}');
$references = substr($accessory['content'], $debut + strlen('{products}'), $fin - $debut - strlen('{products}'));
foreach (explode(",", $references) as $reference) {
array_push($appProduct, $dbProduct->getProductReference($request->getLocale(), $reference)[0]);
}
}
}
return $this->render('produit/produit.html.twig', ['contents' => $contents, 'link' => $linkrewrite, 'breadcrumb' => $breadcrumb, 'productsElectro' => $productsElectro, 'caracteristiques' => $ArrayCaracteristiques2, 'files' => $files, 'accessories' => $accessories, 'appProduct' => $appProduct]);
}
#[Route(
path: ['fr' => '/{_locale}/capteurs-de-couple/{link}', 'en' => '/{_locale}/torque-transducers/{link}'],
name: 'capteurs_couple_produit',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
#[Route(
path: ['fr' => '/{_locale}/sm-capteurs-de-couple/{link}', 'en' => '/{_locale}/torque-transducers/{link}'],
name: 'capteurs_smcouple_produit',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function capteurs_couple_produit(Request $request, DbProduct $dbProduct, EntityManagerInterface $entityManager, $link = null): Response
{
if ($request->getLocale() == 'fr') {
$breadcrumb = array(['name' => 'Capteurs de couple', 'link_rewrite' => 'capteurs-de-couple']);
} else {
$breadcrumb = array(['name' => 'Torque transducers', 'link_rewrite' => 'torque-transducers']);
}
$contents = $dbProduct->getProduct($request->getLocale(), $link);
$linkrewrite = $dbProduct->getLink($contents[0]['id_product'], $request);
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$productsElectro = $dbProduct->getProductsElectro($request->getLocale(), $contents[0]["category_default"]);
$Langue = $request->getLocale() == "fr" ? "1" : "2";
$id_product = $contents[0]["id_product"];
$myproduct = $contents[0];
$categories = [$myproduct["category_default"]];
if (in_array(18, $categories)) {
$AttributGroupe = 6; //instrumentation => ref article
} else {
$AttributGroupe = 5; // capteur => precision
}
$sql = "
SELECT fp.id_feature, fp.id_product , fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.id_product = $id_product ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$SQLArrayFeaturedProduitEnCours = $query->executeQuery()->fetchAllAssociative();
foreach ($SQLArrayFeaturedProduitEnCours as $cle => $infos) {
$ArrayFeaturedProduitEnCours[] = $infos['id_feature'];
}
$tmpattributes = $myproduct["attr_cap"] . "," . $myproduct["attr_prec"];
$tmpattributesid = $myproduct["attr_cap_id"] . "," . $myproduct["attr_prec_id"];
$attributes = [];
foreach (explode(",", $tmpattributes) as $k => $attr) {
$attributes[$k]['id_attribute_group'] = explode(",", $tmpattributesid)[$k];
$attributes[$k]['attribute_name'] = $attr;
}
$attributes2 = array();
foreach ($attributes as $cle => $attribute) {
//id precison ou ref article => 6
if ($attribute['id_attribute_group'] == $AttributGroupe) {
if (substr($attribute['attribute_name'], -1, 1) == ' ') {
$attribute['attribute_name'] = substr($attribute['attribute_name'], 0, -1);
}
$attributes2[$attribute['group_name']]['list'][$attribute['attribute_name']] = $attribute['attribute_name'];
}
}
$reference = $myproduct['reference'];
// on va chercher les caracteristiques des produits dont la reference commence par $reference (exemple : 5000)
$sql = "
SELECT fp.id_feature, fp.id_product, fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.reference LIKE '" . $reference . "\_%' ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$Array = $query->executeQuery()->fetchAllAssociative();
$ArrayCaracteristiques = array();
foreach ($Array as $cle => $infos) {
$PageName = $infos['name'];
$sqlPagesCms = '
SELECT cl.link_rewrite,cl.meta_title,cl.meta_description,cl.id_cms,c.active,ccl.link_rewrite as link2, ccl2.link_rewrite as link1
FROM `pre2398_cms` c
INNER JOIN `pre2398_cms_lang` cl ON cl.id_cms = c.id_cms
INNER JOIN `pre2398_cms_category` cc ON cc.id_cms_category = c.id_cms_category
INNER JOIN `pre2398_cms_category_lang` ccl ON ccl.id_cms_category = cc.id_cms_category
INNER JOIN `pre2398_cms_category` cc2 ON cc2.id_cms_category = cc.id_parent
INNER JOIN `pre2398_cms_category_lang` ccl2 ON ccl2.id_cms_category = cc2.id_cms_category
WHERE cl.id_lang = ' . $Langue . '
AND cl.meta_title = "' . $PageName . '"
';
$query = $entityManager->getConnection()->prepare($sqlPagesCms);
$PageCms = $query->executeQuery()->fetchAllAssociative();
if ($PageCms != array()) {
if ($PageCms[0]['id_cms']) {
$meta_description = $PageCms[0]['meta_description'];
if ($PageCms[0]['active']) {
$url = "";
$url .= $PageCms[0]["link1"] ? "/" . $PageCms[0]["link1"] : "";
$url .= $PageCms[0]["link2"] ? "/" . $PageCms[0]["link2"] : "";
$url .= $PageCms[0]["link_rewrite"] ? "/" . $PageCms[0]["link_rewrite"] : "";
} else {
$url = "";
}
} else {
$meta_description = '';
$url = '';
}
} else {
$meta_description = '';
$url = '';
}
$ref = explode('_', $infos['reference']);
// on ne garde que les caracteristiques qui concernent le produit en cours
if (in_array($infos['id_feature'], $ArrayFeaturedProduitEnCours)) {
$ArrayCaracteristiques[$infos['id_feature']]['FeatureName'] = $infos['name'];
$ArrayCaracteristiques[$infos['id_feature']]['url'] = $url;
$ArrayCaracteristiques[$infos['id_feature']]['meta_description'] = $meta_description;
$infos['value'] = str_replace('[PPQ]', '<', $infos['value']);
$infos['value'] = str_replace('[PGQ]', '>', $infos['value']);
$infos['value'] = str_replace('[EG]', '=', $infos['value']);
$ArrayCaracteristiques[$infos['id_feature']]['Products'][$ref[2]] = array(
'cle' => $ref[2],
'reference' => $infos['reference'],
'value' => $infos['value'],
'nom' => $ref[1]
);
}
}
//cette partie permet de trier le tableau suivant les references des articles/caracteristiques grace a la cle puis on remet la cle/nom qui permettra l'affichage
$ArrayCaracteristiques2 = $ArrayCaracteristiques;
foreach ($ArrayCaracteristiques as $id => $donnees) {
ksort($donnees['Products']);
$ArrayCaracteristiques2[$id]['Products'] = [];
foreach ($donnees['Products'] as $id2 => $donnees2) {
$ArrayCaracteristiques2[$id]['Products'][$donnees2['nom']] = $donnees2;
}
}
// cette partie permet de trier les caracteristiques
$i = 0;
$TabCarac = [];
foreach ($ArrayCaracteristiques2 as $id => $donnees) {
if ($i == 0) {
foreach ($donnees['Products'] as $id2 => $donnees2) {
$TabCarac[$donnees2['nom']] = $donnees2['nom'];
$i++;
}
}
}
$files = $dbProduct->getProductAttachment($request->getLocale(), $myproduct['id_product']);
$accessories = $dbProduct->getProductAccessories($request->getLocale(), $myproduct['id_product']);
$appProduct = [];
foreach($accessories as $accessory) {
if ($accessory['name'] == 'Applications') {
$debut = strpos($accessory['content'], '{products}');
$fin = strpos($accessory['content'], '{/products}');
$references = substr($accessory['content'], $debut + strlen('{products}'), $fin - $debut - strlen('{products}'));
foreach (explode(",", $references) as $reference) {
array_push($appProduct, $dbProduct->getProductReference($request->getLocale(), $reference)[0]);
}
}
}
if ($request->attributes->get('_route') == 'capteurs_smcouple_produit') {
$render = 'produit/smproduit.html.twig';
} else {
$render = 'produit/produit.html.twig';
}
return $this->render($render, ['contents' => $contents, 'link' => $linkrewrite, 'breadcrumb' => $breadcrumb, 'productsElectro' => $productsElectro, 'caracteristiques' => $ArrayCaracteristiques2, 'files' => $files, 'accessories' => $accessories, 'appProduct' => $appProduct]);
}
#[Route(
path: ['fr' => '/{_locale}/tensiometres/{link}', 'en' => '/{_locale}/tensiometers/{link}'],
name: 'tensiometres_produit',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function tensiometres_produit(Request $request, DbProduct $dbProduct, EntityManagerInterface $entityManager, $link = null): Response
{
if ($request->getLocale() == 'fr') {
$breadcrumb = array(['name' => 'Tensiomètres', 'link_rewrite' => 'tensiometres']);
} else {
$breadcrumb = array(['name' => 'Tensiometers', 'link_rewrite' => 'tensiometers']);
}
$contents = $dbProduct->getProduct($request->getLocale(), $link);
$linkrewrite = $dbProduct->getLink($contents[0]['id_product'], $request);
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$productsElectro = $dbProduct->getProductsElectro($request->getLocale(), $contents[0]["category_default"]);
$Langue = $request->getLocale() == "fr" ? "1" : "2";
$id_product = $contents[0]["id_product"];
$myproduct = $contents[0];
$categories = [$myproduct["category_default"]];
if (in_array(18, $categories)) {
$AttributGroupe = 6; //instrumentation => ref article
} else {
$AttributGroupe = 5; // capteur => precision
}
$sql = "
SELECT fp.id_feature, fp.id_product , fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.id_product = $id_product ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$SQLArrayFeaturedProduitEnCours = $query->executeQuery()->fetchAllAssociative();
foreach ($SQLArrayFeaturedProduitEnCours as $cle => $infos) {
$ArrayFeaturedProduitEnCours[] = $infos['id_feature'];
}
$tmpattributes = $myproduct["attr_cap"] . "," . $myproduct["attr_prec"];
$tmpattributesid = $myproduct["attr_cap_id"] . "," . $myproduct["attr_prec_id"];
$attributes = [];
foreach (explode(",", $tmpattributes) as $k => $attr) {
$attributes[$k]['id_attribute_group'] = explode(",", $tmpattributesid)[$k];
$attributes[$k]['attribute_name'] = $attr;
}
$attributes2 = array();
foreach ($attributes as $cle => $attribute) {
//id precison ou ref article => 6
if ($attribute['id_attribute_group'] == $AttributGroupe) {
if (substr($attribute['attribute_name'], -1, 1) == ' ') {
$attribute['attribute_name'] = substr($attribute['attribute_name'], 0, -1);
}
$attributes2[$attribute['group_name']]['list'][$attribute['attribute_name']] = $attribute['attribute_name'];
}
}
$reference = $myproduct['reference'];
// on va chercher les caracteristiques des produits dont la reference commence par $reference (exemple : 5000)
$sql = "
SELECT fp.id_feature, fp.id_product, fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.reference LIKE '" . $reference . "\_%' ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$Array = $query->executeQuery()->fetchAllAssociative();
$ArrayCaracteristiques = array();
foreach ($Array as $cle => $infos) {
$PageName = $infos['name'];
$sqlPagesCms = '
SELECT cl.link_rewrite,cl.meta_title,cl.meta_description,cl.id_cms,c.active,ccl.link_rewrite as link2, ccl2.link_rewrite as link1
FROM `pre2398_cms` c
INNER JOIN `pre2398_cms_lang` cl ON cl.id_cms = c.id_cms
INNER JOIN `pre2398_cms_category` cc ON cc.id_cms_category = c.id_cms_category
INNER JOIN `pre2398_cms_category_lang` ccl ON ccl.id_cms_category = cc.id_cms_category
INNER JOIN `pre2398_cms_category` cc2 ON cc2.id_cms_category = cc.id_parent
INNER JOIN `pre2398_cms_category_lang` ccl2 ON ccl2.id_cms_category = cc2.id_cms_category
WHERE cl.id_lang = ' . $Langue . '
AND cl.meta_title = "' . $PageName . '"
';
$query = $entityManager->getConnection()->prepare($sqlPagesCms);
$PageCms = $query->executeQuery()->fetchAllAssociative();
if ($PageCms != array()) {
if ($PageCms[0]['id_cms']) {
$meta_description = $PageCms[0]['meta_description'];
if ($PageCms[0]['active']) {
$url = "";
$url .= $PageCms[0]["link1"] ? "/" . $PageCms[0]["link1"] : "";
$url .= $PageCms[0]["link2"] ? "/" . $PageCms[0]["link2"] : "";
$url .= $PageCms[0]["link_rewrite"] ? "/" . $PageCms[0]["link_rewrite"] : "";
} else {
$url = "";
}
} else {
$meta_description = '';
$url = '';
}
} else {
$meta_description = '';
$url = '';
}
$ref = explode('_', $infos['reference']);
// on ne garde que les caracteristiques qui concernent le produit en cours
if (in_array($infos['id_feature'], $ArrayFeaturedProduitEnCours)) {
$ArrayCaracteristiques[$infos['id_feature']]['FeatureName'] = $infos['name'];
$ArrayCaracteristiques[$infos['id_feature']]['url'] = $url;
$ArrayCaracteristiques[$infos['id_feature']]['meta_description'] = $meta_description;
$infos['value'] = str_replace('[PPQ]', '<', $infos['value']);
$infos['value'] = str_replace('[PGQ]', '>', $infos['value']);
$infos['value'] = str_replace('[EG]', '=', $infos['value']);
$ArrayCaracteristiques[$infos['id_feature']]['Products'][$ref[2]] = array(
'cle' => $ref[2],
'reference' => $infos['reference'],
'value' => $infos['value'],
'nom' => $ref[1]
);
}
}
//cette partie permet de trier le tableau suivant les references des articles/caracteristiques grace a la cle puis on remet la cle/nom qui permettra l'affichage
$ArrayCaracteristiques2 = $ArrayCaracteristiques;
foreach ($ArrayCaracteristiques as $id => $donnees) {
ksort($donnees['Products']);
$ArrayCaracteristiques2[$id]['Products'] = [];
foreach ($donnees['Products'] as $id2 => $donnees2) {
$ArrayCaracteristiques2[$id]['Products'][$donnees2['nom']] = $donnees2;
}
}
// cette partie permet de trier les caracteristiques
$i = 0;
$TabCarac = [];
foreach ($ArrayCaracteristiques2 as $id => $donnees) {
if ($i == 0) {
foreach ($donnees['Products'] as $id2 => $donnees2) {
$TabCarac[$donnees2['nom']] = $donnees2['nom'];
$i++;
}
}
}
$files = $dbProduct->getProductAttachment($request->getLocale(), $myproduct['id_product']);
$accessories = $dbProduct->getProductAccessories($request->getLocale(), $myproduct['id_product']);
$appProduct = [];
foreach ($accessories as $accessory) {
if ($accessory['name'] == 'Applications') {
$debut = strpos($accessory['content'], '{products}');
$fin = strpos($accessory['content'], '{/products}');
$references = substr($accessory['content'], $debut + strlen('{products}'), $fin - $debut - strlen('{products}'));
foreach (explode(",", $references) as $reference) {
array_push($appProduct, $dbProduct->getProductReference($request->getLocale(), $reference)[0]);
}
}
}
return $this->render('produit/produit.html.twig', ['contents' => $contents, 'link' => $linkrewrite, 'breadcrumb' => $breadcrumb, 'productsElectro' => $productsElectro, 'caracteristiques' => $ArrayCaracteristiques2, 'files' => $files, 'accessories' => $accessories, 'appProduct' => $appProduct]);
}
#[Route(
path: ['fr' => '/{_locale}/instrumentation/{link}', 'en' => '/{_locale}/instrumentation/{link}'],
name: 'instrumentation_produit',
requirements: [
'_locale' => 'en|fr',
],
priority: 2
)]
public function instrumentation_produit(Request $request, DbProduct $dbProduct, EntityManagerInterface $entityManager, $link = null): Response
{
if ($request->getLocale() == 'fr') {
$breadcrumb = array(['name' => 'Instrumentation', 'link_rewrite' => 'instrumentation']);
} else {
$breadcrumb = array(['name' => 'Instrumentation', 'link_rewrite' => 'instrumentation']);
}
$contents = $dbProduct->getProduct($request->getLocale(), $link);
$linkrewrite = $dbProduct->getLink($contents[0]['id_product'], $request);
foreach ($contents as $k => $content) {
$contents[$k]["meta_title"] = $content["name"];
}
$productsElectro = $dbProduct->getProductsElectro($request->getLocale(), $contents[0]["category_default"]);
$Langue = $request->getLocale() == "fr" ? "1" : "2";
$id_product = $contents[0]["id_product"];
$myproduct = $contents[0];
$categories = [$myproduct["category_default"]];
if (in_array(18, $categories)) {
$AttributGroupe = 6; //instrumentation => ref article
} else {
$AttributGroupe = 5; // capteur => precision
}
$sql = "
SELECT fp.id_feature, fp.id_product , fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.id_product = $id_product ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$SQLArrayFeaturedProduitEnCours = $query->executeQuery()->fetchAllAssociative();
foreach ($SQLArrayFeaturedProduitEnCours as $cle => $infos) {
$ArrayFeaturedProduitEnCours[] = $infos['id_feature'];
}
$tmpattributes = $myproduct["attr_cap"] . "," . $myproduct["attr_prec"];
$tmpattributesid = $myproduct["attr_cap_id"] . "," . $myproduct["attr_prec_id"];
$attributes = [];
foreach (explode(",", $tmpattributes) as $k => $attr) {
$attributes[$k]['id_attribute_group'] = explode(",", $tmpattributesid)[$k];
$attributes[$k]['attribute_name'] = $attr;
}
$attributes2 = array();
foreach ($attributes as $cle => $attribute) {
//id precison ou ref article => 6
if ($attribute['id_attribute_group'] == $AttributGroupe) {
if (substr($attribute['attribute_name'], -1, 1) == ' ') {
$attribute['attribute_name'] = substr($attribute['attribute_name'], 0, -1);
}
$attributes2[$attribute['group_name']]['list'][$attribute['attribute_name']] = $attribute['attribute_name'];
}
}
$reference = $myproduct['reference'];
// on va chercher les caracteristiques des produits dont la reference commence par $reference (exemple : 5000)
$sql = "
SELECT fp.id_feature, fp.id_product, fl.name, p.reference, p.id_product, fvl.value
FROM `pre2398_feature_product` fp
INNER JOIN `pre2398_feature_value_lang` fvl ON fp.id_feature_value = fvl.id_feature_value
INNER JOIN `pre2398_feature_lang` fl ON fp.id_feature = fl.id_feature
INNER JOIN `pre2398_product` p ON fp.id_product = p.id_product
INNER JOIN `pre2398_feature` f ON f.id_feature = fl.id_feature
WHERE fl.id_lang = $Langue AND fvl.id_lang = $Langue AND p.reference LIKE '" . $reference . "\_%' ORDER BY f.position";
$query = $entityManager->getConnection()->prepare($sql);
$Array = $query->executeQuery()->fetchAllAssociative();
$ArrayCaracteristiques = array();
foreach ($Array as $cle => $infos) {
$PageName = $infos['name'];
$sqlPagesCms = '
SELECT cl.link_rewrite,cl.meta_title,cl.meta_description,cl.id_cms,c.active,ccl.link_rewrite as link2, ccl2.link_rewrite as link1
FROM `pre2398_cms` c
INNER JOIN `pre2398_cms_lang` cl ON cl.id_cms = c.id_cms
INNER JOIN `pre2398_cms_category` cc ON cc.id_cms_category = c.id_cms_category
INNER JOIN `pre2398_cms_category_lang` ccl ON ccl.id_cms_category = cc.id_cms_category
INNER JOIN `pre2398_cms_category` cc2 ON cc2.id_cms_category = cc.id_parent
INNER JOIN `pre2398_cms_category_lang` ccl2 ON ccl2.id_cms_category = cc2.id_cms_category
WHERE cl.id_lang = ' . $Langue . '
AND cl.meta_title = "' . $PageName . '"
';
$query = $entityManager->getConnection()->prepare($sqlPagesCms);
$PageCms = $query->executeQuery()->fetchAllAssociative();
if ($PageCms != array()) {
if ($PageCms[0]['id_cms']) {
$meta_description = $PageCms[0]['meta_description'];
if ($PageCms[0]['active']) {
$url = "";
$url .= $PageCms[0]["link1"] ? "/" . $PageCms[0]["link1"] : "";
$url .= $PageCms[0]["link2"] ? "/" . $PageCms[0]["link2"] : "";
$url .= $PageCms[0]["link_rewrite"] ? "/" . $PageCms[0]["link_rewrite"] : "";
} else {
$url = "";
}
} else {
$meta_description = '';
$url = '';
}
} else {
$meta_description = '';
$url = '';
}
$ref = explode('_', $infos['reference']);
// on ne garde que les caracteristiques qui concernent le produit en cours
if (in_array($infos['id_feature'], $ArrayFeaturedProduitEnCours)) {
$ArrayCaracteristiques[$infos['id_feature']]['FeatureName'] = $infos['name'];
$ArrayCaracteristiques[$infos['id_feature']]['url'] = $url;
$ArrayCaracteristiques[$infos['id_feature']]['meta_description'] = $meta_description;
$infos['value'] = str_replace('[PPQ]', '<', $infos['value']);
$infos['value'] = str_replace('[PGQ]', '>', $infos['value']);
$infos['value'] = str_replace('[EG]', '=', $infos['value']);
$ArrayCaracteristiques[$infos['id_feature']]['Products'][$ref[2]] = array(
'cle' => $ref[2],
'reference' => $infos['reference'],
'value' => $infos['value'],
'nom' => $ref[1],
'id' => $infos['id_product']
);
}
}
//cette partie permet de trier le tableau suivant les references des articles/caracteristiques grace a la cle puis on remet la cle/nom qui permettra l'affichage
$ArrayCaracteristiques2 = $ArrayCaracteristiques;
foreach ($ArrayCaracteristiques as $id => $donnees) {
ksort($donnees['Products']);
$ArrayCaracteristiques2[$id]['Products'] = [];
foreach ($donnees['Products'] as $id2 => $donnees2) {
$ArrayCaracteristiques2[$id]['Products'][$donnees2['nom']] = $donnees2;
}
}
// cette partie permet de trier les caracteristiques
$i = 0;
$TabCarac = [];
foreach ($ArrayCaracteristiques2 as $id => $donnees) {
if ($i == 0) {
foreach ($donnees['Products'] as $id2 => $donnees2) {
$TabCarac[$donnees2['nom']] = $donnees2['nom'];
$i++;
}
}
}
$files = $dbProduct->getProductAttachment($request->getLocale(), $myproduct['id_product']);
$accessories = $dbProduct->getProductAccessories($request->getLocale(), $myproduct['id_product']);
$appProduct = [];
foreach ($accessories as $accessory) {
if ($accessory['name'] == 'Applications') {
$debut = strpos($accessory['content'], '{products}');
$fin = strpos($accessory['content'], '{/products}');
$references = substr($accessory['content'], $debut + strlen('{products}'), $fin - $debut - strlen('{products}'));
foreach (explode(",", $references) as $reference) {
array_push($appProduct, $dbProduct->getProductReference($request->getLocale(), $reference)[0]);
}
}
}
return $this->render('produit/produit.html.twig', ['contents' => $contents, 'link' => $linkrewrite, 'breadcrumb' => $breadcrumb, 'productsElectro' => $productsElectro, 'caracteristiques' => $ArrayCaracteristiques2, 'files' => $files, 'accessories' => $accessories, 'appProduct' => $appProduct]);
}
}