Guest User

Untitled

a guest
Jan 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
  2. <group id="cpm_order_cron">
  3. <job name="cpm_order_reminder" instance="CpmOrderCronContractEndReminder" method="execute">
  4. <schedule>15 10 * * *</schedule>
  5. </job>
  6. </group>
  7.  
  8. public function execute()
  9. {
  10. $fh = fopen("/var/www/html/var/log/cron_log","a");
  11. fwrite($fh,"Start Time: ".date("Y-m-d H:i:s")."n");
  12. $model = $this->OrderPriceFactory->create();
  13. $orders = $model->getCollection();
  14.  
  15.  
  16. foreach($orders->getItems() as $op)
  17. {
  18. fwrite($fh,"Contract End: ".$op->getContractEnd()."n");
  19. $order = $this->OrderFactory->create()->load($op->getOrderId());
  20. $customer = $this->objectManager->get("MagentoCustomerModelCustomer")->load($order->getCustomerId());
  21. $sendData = array(
  22. "op_id"=>$op->getId(),
  23. "order_id"=>$op->getOrderId(),
  24. "contract_id"=>$order->getIncrementId(),
  25. "order_status"=>$order->getStatusLabel(),
  26. "purchased_date"=>$order->getCreatedAt(),
  27. "contract_start"=>$op->getContractStart(),
  28. "contract_end"=>$op->getContractEnd(),
  29. "customer_name"=>$customer->getFirstname(),
  30. "customer_email"=>$customer->getEmail()
  31. );
  32. $this->sendemail($customer->getEmail(),$sendData);
  33. }
  34. fclose($fh);
  35. }
Add Comment
Please, Sign In to add comment