Reputation: 111
I want to get all applicable catalog product rules for particular product. How can I achieve this?
Upvotes: 0
Views: 934
Reputation: 19
I know this probably isn't the best answer as to people not wanting you to use the objectmanager, but here is a dirty way:
<?php
//Get Object Manager Instance
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
//Load product by product id
$rules = $objectManager->create('Magento\CatalogRule\Model\ResourceModel\Rule')->getRulesFromProduct($date, $websiteId, $customerGroupId, $productId);
You will need to get the variables from where ever your code is ( template file, or class etc )
Upvotes: 1