What I'm trying to do is create from which all the attributes of these products will be requested. I have 4 different types of product. One type of product is a group product, and when the product is a group product, we need to navigate through all the subproducts of the group product and request the attribute of all subfiles. I don’t want to duplicate code based on the type of product, so try using the PHP Eval () function to start and close the loop when required. But some, how it does not work, can someone please hepl me?
Here is my code
$arrProdInfo = getProductInfo($prodId);
$pName = $arrProdInfo['name'];
$pCode = $arrProdInfo['code'];
$pType = $arrProdInfo['producttype'];
$topStr1 = "";
$botStr1 = "";
if ($pType == "G") {
$rsltGroupProd = getGroupProd($prodId);
$topStr1 = "while($rowGroupProd = $rsltGroupProd->fetchAssoc()){
$prodId = $rowGroupProd['relproductid'];
if(!is_numeric($prodId)) $prodId = 0;
$pName = $rowGroupProd['name'];
$pCode = $rowGroupProd['code'];
$pType = $rowGroupProd['producttype'];
";
$botStr1 = "}";
}
eval($topStr1);
eval($botStr1);
source
share