I have tried these
$currentDate = $this->_stdTimezone->date()->format('Y-m-d');
$rules = $this->collection->create()
->addFieldToFilter('is_active', 1)
->addFieldToFilter('from_date', ['lteq' => $currentDate])
->addFieldToFilter('from_date', ['neq' => 'NULL']);
$product = $this->_coreRegistry->registry('product');
foreach ($rules as $rule) {
try {
if ($rule->getActions()->validate($product)) {
$activeRules[] = $rule;
}
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
continue;
}
}
$rulesApplied = "";
foreach ($rules as $rule) {
$code = $rule->getCode();
$rulesApplied .= "<strong>".$code."</strong>"."</br>";
}
return $rulesApplied;
but i am getting all the rules which are satisfying the given conditions.I need only the rules which are applied to a products.