product loop : feature_values param + fix feature_av
This commit is contained in:
@@ -94,6 +94,12 @@ class Product extends BaseLoop
|
|||||||
new TypeCollection(
|
new TypeCollection(
|
||||||
new Type\IntToCombinedIntsListType()
|
new Type\IntToCombinedIntsListType()
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
new Argument(
|
||||||
|
'feature_values',
|
||||||
|
new TypeCollection(
|
||||||
|
new Type\IntToCombinedStringsListType()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -333,12 +339,40 @@ class Product extends BaseLoop
|
|||||||
if($sqlWhereString == '*') {
|
if($sqlWhereString == '*') {
|
||||||
$sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)';
|
$sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)';
|
||||||
} else {
|
} else {
|
||||||
$sqlWhereString = preg_replace('#(^|[^0-9])([0-9]+)([^0-9]|$)#', '\1NOT ISNULL(`fa_' . $feature . '_' . '\2`.ID)\3', $sqlWhereString);
|
$sqlWhereString = preg_replace('#([0-9]+)#', 'NOT ISNULL(`fa_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
|
||||||
$sqlWhereString = str_replace('&', ' AND ', $sqlWhereString);
|
$sqlWhereString = str_replace('&', ' AND ', $sqlWhereString);
|
||||||
$sqlWhereString = str_replace('|', ' OR ', $sqlWhereString);
|
$sqlWhereString = str_replace('|', ' OR ', $sqlWhereString);
|
||||||
}
|
}
|
||||||
|
|
||||||
$search->where($sqlWhereString);
|
$search->where("(" . $sqlWhereString . ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$feature_values = $this->getFeature_values();
|
||||||
|
|
||||||
|
if(null !== $feature_values) {
|
||||||
|
foreach($feature_values as $feature => $feature_choice) {
|
||||||
|
foreach($feature_choice['values'] as $feature_value) {
|
||||||
|
$featureAlias = 'fv_' . $feature;
|
||||||
|
if($feature_value != '*')
|
||||||
|
$featureAlias .= '_' . $feature_value;
|
||||||
|
$search->joinFeatureProd($featureAlias, Criteria::LEFT_JOIN)
|
||||||
|
->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_ID = ?", $feature, null, \PDO::PARAM_INT);
|
||||||
|
if($feature_value != '*')
|
||||||
|
$search->addJoinCondition($featureAlias, "`$featureAlias`.BY_DEFAULT = ?", $feature_value, null, \PDO::PARAM_STR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* format for mysql */
|
||||||
|
$sqlWhereString = $feature_choice['expression'];
|
||||||
|
if($sqlWhereString == '*') {
|
||||||
|
$sqlWhereString = 'NOT ISNULL(`fv_' . $feature . '`.ID)';
|
||||||
|
} else {
|
||||||
|
$sqlWhereString = preg_replace('#([a-zA-Z0-9_\-]+)#', 'NOT ISNULL(`fv_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
|
||||||
|
$sqlWhereString = str_replace('&', ' AND ', $sqlWhereString);
|
||||||
|
$sqlWhereString = str_replace('|', ' OR ', $sqlWhereString);
|
||||||
|
}
|
||||||
|
|
||||||
|
$search->where("(" . $sqlWhereString . ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,8 +407,6 @@ class Product extends BaseLoop
|
|||||||
$loopResultRow->set("PROMO", $product->getPromo());
|
$loopResultRow->set("PROMO", $product->getPromo());
|
||||||
$loopResultRow->set("NEW", $product->getNewness());
|
$loopResultRow->set("NEW", $product->getNewness());
|
||||||
|
|
||||||
//$loopResultRow->set("URL", $product->getUrl());
|
|
||||||
|
|
||||||
$loopResult->addRow($loopResultRow);
|
$loopResult->addRow($loopResultRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,16 @@
|
|||||||
weight : #WEIGHT<br />
|
weight : #WEIGHT<br />
|
||||||
{/loop*}
|
{/loop*}
|
||||||
|
|
||||||
{loop name="product" type="product" order="ref" feature_available="1: (1 | 2) , 2: 4, 3: 433"}
|
{*loop name="product" type="product" order="ref" feature_available="1: (1 | 2) , 2: 4, 3: 433"}
|
||||||
|
<h3>PRODUCT : #REF / #TITLE</h3>
|
||||||
|
price : #PRICE €<br />
|
||||||
|
promo price : #PROMO_PRICE €<br />
|
||||||
|
is promo : #PROMO<br />
|
||||||
|
is new : #NEW<br />
|
||||||
|
weight : #WEIGHT<br />
|
||||||
|
{/loop*}
|
||||||
|
|
||||||
|
{loop name="product" type="product" order="ref" feature_values="1: foo"}
|
||||||
<h3>PRODUCT : #REF / #TITLE</h3>
|
<h3>PRODUCT : #REF / #TITLE</h3>
|
||||||
price : #PRICE €<br />
|
price : #PRICE €<br />
|
||||||
promo price : #PROMO_PRICE €<br />
|
promo price : #PROMO_PRICE €<br />
|
||||||
|
|||||||
Reference in New Issue
Block a user