I am trying to get Cart_Price_Rule.

   public function test()
    $ruleArray = $this->adventCollectionFactory->create()->getData();
    $ruleArray = array_column($ruleArray,'promo_rule_id');
    return implode($ruleArray);

This allows me to see the 2 rule id i have pased in a collection

But how would I check it with rule repository individually My results are 1 and 2 and I have a cart price rule which has the ID of 1 and 2 I am trying to grab the description and code in phtml

\Magento\SalesRule\Model\RuleRepository $ruleRepository 
$rule = $this->ruleRepository->getById($this->test()); //how do i pass it individually the id's

    public function test(){

    $ruleArray = $this->adventCollectionFactory->create()->getData();
    $ruleArray = array_column($ruleArray,'promo_rule_id');
    $array=  implode($ruleArray);



I get 1 and 2 - which is correct

|improve this answer|||||
  • try this explode(',',$this->test()) – Rk Rathod Sep 6 '19 at 15:12
  • Didn't work i get this following error 1 exception(s): Exception #0 (Magento\Framework\Exception\NoSuchEntityException): No such entity. – jibin george Sep 6 '19 at 15:16
  • check which type of data getting in $this->test() try this print_r($this->test()) – Rk Rathod Sep 6 '19 at 15:17
  • I have updated it How do I do the foreach – jibin george Sep 6 '19 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.