Hi,
I’m running into a problem getting the property name and value. When I set the variable values by hand using $name = „Typ“; and $value = „Rollo“; the templates work fine. But soon as I use the original code (line 24 and 25) Shopware returns the 404 template.
If anyone spots the issue that would be great!
<?php
class Shopware_Controllers_Frontend_Productconfigurator extends Enlight_Controller_Action
{
public function indexAction()
{
$view = $this->View();
$request = $this->Request();
$artikelnummer = $request->getParam("artikelnummer");
if (empty($artikelnummer)) {
$artikelnummer = Shopware()->Config()->get("default_article");
} else {
$orderNumber = $artikelnummer;
if (empty($orderNumber)) {
return NULL;
}
$articleModule = Shopware()->Modules()->Articles();
$sArticle = $articleModule->sGetProductByOrdernumber($orderNumber);
$name = $this->slugify($sProperty["name"]);
$value = $sProperty["value"];
// $name = "Typ";
// $value = "Rollo";
if ($name == "Typ") {
$product_type = $value;
if ($product_type == "Rollo") {
$view->loadTemplate("frontend/konfigurator/rollo.tpl");
} else {
if ($product_type == "Plissee") {
$view->loadTemplate("frontend/konfigurator/plissee.tpl");
} else {
if ($product_type == "Doppelrollo") {
$view->loadTemplate("frontend/konfigurator/duorollo.tpl");
} else {
if ($product_type == "Holzjalousie") {
$view->loadTemplate("frontend/konfigurator/holzjalousie.tpl");
}
}
}
}
// $name = strtolower(trim(preg_replace("/[^A-Za-z0-9-]+/", "-", $sProperty["name"])));
// $value = $sProperty["value"];
$name = $this->slugify($sProperty["name"]);
$value = $sProperty["value"];
$view->assign("prop_" . $name, $value);
$view->assign("sArticle", $sArticle);
}
}
}
public static function slugify($text)
{
// replace non letter or digits by divider
$text = preg_replace("~[^\pL\d]+~u", "-", $text);
// transliterate
$text = iconv("utf-8", "us-ascii//TRANSLIT", $text);
// remove unwanted characters
$text = preg_replace("~[^-\w]+~", "", $text);
// trim
$text = trim($text, "-");
// remove duplicate divider
$text = preg_replace("~-+~", "-", $text);
// lowercase
$text = strtolower($text);
if (empty($text)) {
return "n-a";
}
return $text;
}
}
?>