Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
- <group id="cpm_order_cron">
- <job name="cpm_order_reminder" instance="CpmOrderCronContractEndReminder" method="execute">
- <schedule>15 10 * * *</schedule>
- </job>
- </group>
- public function execute()
- {
- $fh = fopen("/var/www/html/var/log/cron_log","a");
- fwrite($fh,"Start Time: ".date("Y-m-d H:i:s")."n");
- $model = $this->OrderPriceFactory->create();
- $orders = $model->getCollection();
- foreach($orders->getItems() as $op)
- {
- fwrite($fh,"Contract End: ".$op->getContractEnd()."n");
- $order = $this->OrderFactory->create()->load($op->getOrderId());
- $customer = $this->objectManager->get("MagentoCustomerModelCustomer")->load($order->getCustomerId());
- $sendData = array(
- "op_id"=>$op->getId(),
- "order_id"=>$op->getOrderId(),
- "contract_id"=>$order->getIncrementId(),
- "order_status"=>$order->getStatusLabel(),
- "purchased_date"=>$order->getCreatedAt(),
- "contract_start"=>$op->getContractStart(),
- "contract_end"=>$op->getContractEnd(),
- "customer_name"=>$customer->getFirstname(),
- "customer_email"=>$customer->getEmail()
- );
- $this->sendemail($customer->getEmail(),$sendData);
- }
- fclose($fh);
- }
Add Comment
Please, Sign In to add comment