PHP Classes

File: demo/ChangeCustomerOrders.php

Recommend this page to a friend!
  Classes of Oleksii Mylotskyi   PHP MoySklad Client   demo/ChangeCustomerOrders.php   Download  
File: demo/ChangeCustomerOrders.php
Role: Example script
Content type: text/plain
Description: Demo Files
Class: PHP MoySklad Client
Access the MoySklad API using ORM like objects
Author: By
Last change:
Date: 8 years ago
Size: 1,084 bytes
 

Contents

Class file image Download
<?php
namespace Zf2ClientMoysklad;

require_once
__DIR__.'/_config.php';

use
Zf2ClientMoysklad\Entity\CustomerOrder;
use
Zf2ClientMoysklad\Entity\Good;
use
Zf2ClientMoysklad\Entity\PurchaseOrder;
use
Zf2ClientMoysklad\Repository\BasicRepository;

global
$sm;

/* @var $entityManager EntityManager */
$entityManager = $sm->get('zf2clientmoysklad_entity_manager');

/*====================== Method for sending payments ==========================*/

/* @var $repository BasicRepository */
$repository = $entityManager->getRepository('Zf2ClientMoysklad\Entity\CustomerOrder');

/* @var $customerOrders CustomerOrder[] */
$customerOrders = $repository->findAll(array('externalCode = '=>array('22684')));

foreach (
$customerOrders as $orderEntity) {
    foreach (
$orderEntity->getOrderPosition() as $orderPosition) {
       
/* @var CustomerOrder\Position $orderPosition */
       
$orderPosition->setQuantity(rand(1,9999));
    }
   
$entityManager->persist($orderEntity);
}

$entityManager->flush();

/*---------------------------------------------------------------------------------*/