我要将Shopware 6 Backend中定义的一些值放入MultiFilter.有没有人能给出一个实施方面的建议?
我可以以某种方式循环访问多重过滤器中的前缀吗?
它肯定不起作用,但我只是想给出我试图在Subcriber.php上设置的内容的 idea :
// Here I will receive text strings
$prefixes = ['Aaa', 'Bbb', 'Ccc', 'Ddd'];
$ii = 0;
// To use in PrefixFilter
if (in_array('3f777000a2734deead391133cee3a6a9', $currentPropertyOptions)) {
$criteria->addFilter(
new MultiFilter(
Multifilter::CONNECTION_OR,
[
// This is the idea
while($ii < count($prefixes))
{
echo "new PrefixFilter('product.properties.name', '$prefixes[$i]'),";
$ii++;
}
// It should work like this
new PrefixFilter('product.properties.name', 'Aaa'),
new PrefixFilter('product.properties.name', 'Bbb'),
new PrefixFilter('product.properties.name', 'Ccc'),
new PrefixFilter('product.properties.name', 'Ddd'),
// Other filters
new EqualsFilter('product.properties.group.name', 'G1'),
new EqualsFilter('product.properties.group.name', 'G2'),
..
]
)
);
}