Skip to content

Commit c88cea2

Browse files
committed
added support for arbitory attriubtes placeholder
1 parent f83ffc3 commit c88cea2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Model/Product/Enricher.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ public function getAttributes()
3333
*/
3434
public function parsePrompt($prompt, $product): String
3535
{
36-
return str_replace(
37-
['{{name}}', '{{sku}}'],
38-
[$product->getName(), $product->getSku()],
39-
$prompt
40-
);
36+
$prompt = preg_replace_callback('/\{\{(.+?)\}\}/', function ($matches) use ($product) {
37+
return $product->getData($matches[1]);
38+
}, $prompt);
39+
return $prompt;
4140
}
4241

4342
public function enrichAttribute($product, $attributeCode)

0 commit comments

Comments
 (0)