/** * Update product export date for the given product * @param string $identifier * @param JobInstance $jobInstance */ public function updateProductExport($identifier, JobInstance $jobInstance) { $now = new \DateTime('now', new \DateTimeZone('UTC')); $product = $this->productRepository->findByReference((string) $identifier); if (class_exists('\\PimEnterprise\\Bundle\\WorkflowBundle\\Model\\PublishedProduct')) { if ($product instanceof \PimEnterprise\Bundle\WorkflowBundle\Model\PublishedProduct) { /**@var \PimEnterprise\Bundle\WorkflowBundle\Model\PublishedProduct $product **/ $productId = $product->getOriginalProduct()->getId(); $product = $product->getOriginalProduct(); } } if (null != $product) { $productExport = $this->productExportRepository->findOneBy(array('product' => $product, 'jobInstance' => $jobInstance)); $conn = $this->entityManager->getConnection(); $jobInstance->getId(); $product->getId(); if (null === $productExport) { $sql = ' INSERT INTO pim_delta_product_export (product_id, job_instance_id, date) VALUES (:product_id, :job_instance_id, :date) '; } else { $sql = ' UPDATE pim_delta_product_export SET date = :date WHERE product_id = :product_id AND job_instance_id = :job_instance_id '; } $q = $conn->prepare($sql); $date = $now->format('Y-m-d H:i:s'); $productId = $product->getId(); $jobInstanceId = $jobInstance->getId(); $q->bindParam(':date', $date, PDO::PARAM_STR); $q->bindParam(':product_id', $productId, PDO::PARAM_INT); $q->bindParam(':job_instance_id', $jobInstanceId, PDO::PARAM_INT); $q->execute(); } }