PageRenderTime 55ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php

https://bitbucket.org/andrewjleavitt/magestudy
PHP | 751 lines | 526 code | 104 blank | 121 comment | 101 complexity | d2f575aadfba6b604b25ee27a7993ed1 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-2.1, GPL-2.0, WTFPL
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Customer
  23. * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. class Mage_Customer_Model_Convert_Adapter_Customer
  27. extends Mage_Eav_Model_Convert_Adapter_Entity
  28. {
  29. const MULTI_DELIMITER = ' , ';
  30. /**
  31. * Customer model
  32. *
  33. * @var Mage_Customer_Model_Customer
  34. */
  35. protected $_customerModel;
  36. protected $_stores;
  37. protected $_attributes = array();
  38. protected $_customerGroups;
  39. protected $_billingAddressModel;
  40. protected $_shippingAddressModel;
  41. protected $_requiredFields = array();
  42. protected $_ignoreFields = array();
  43. protected $_billingFields = array();
  44. protected $_billingMappedFields = array();
  45. protected $_billingStreetFields = array();
  46. protected $_billingRequiredFields = array();
  47. protected $_shippingFields = array();
  48. protected $_shippingMappedFields = array();
  49. protected $_shippingStreetFields= array();
  50. protected $_shippingRequiredFields = array();
  51. protected $_addressFields = array();
  52. protected $_regions;
  53. protected $_websites;
  54. protected $_customer = null;
  55. protected $_address = null;
  56. protected $_customerId = '';
  57. /**
  58. * Retrieve customer model cache
  59. *
  60. * @return Mage_Customer_Model_Customer
  61. */
  62. public function getCustomerModel()
  63. {
  64. if (is_null($this->_customerModel)) {
  65. $object = Mage::getModel('customer/customer');
  66. $this->_customerModel = Mage::objects()->save($object);
  67. }
  68. return Mage::objects()->load($this->_customerModel);
  69. }
  70. /**
  71. * Retrieve customer address model cache
  72. *
  73. * @return Mage_Customer_Model_Address
  74. */
  75. public function getBillingAddressModel()
  76. {
  77. if (is_null($this->_billingAddressModel)) {
  78. $object = Mage::getModel('customer/address');
  79. $this->_billingAddressModel = Mage::objects()->save($object);
  80. }
  81. return Mage::objects()->load($this->_billingAddressModel);
  82. }
  83. /**
  84. * Retrieve customer address model cache
  85. *
  86. * @return Mage_Customer_Model_Address
  87. */
  88. public function getShippingAddressModel()
  89. {
  90. if (is_null($this->_shippingAddressModel)) {
  91. $object = Mage::getModel('customer/address');
  92. $this->_shippingAddressModel = Mage::objects()->save($object);
  93. }
  94. return Mage::objects()->load($this->_shippingAddressModel);
  95. }
  96. /**
  97. * Retrieve store object by code
  98. *
  99. * @param string $store
  100. * @return Mage_Core_Model_Store
  101. */
  102. public function getStoreByCode($store)
  103. {
  104. if (is_null($this->_stores)) {
  105. $this->_stores = Mage::app()->getStores(true, true);
  106. }
  107. if (isset($this->_stores[$store])) {
  108. return $this->_stores[$store];
  109. }
  110. return false;
  111. }
  112. /**
  113. * Retrieve website model by code
  114. *
  115. * @param int $websiteId
  116. * @return Mage_Core_Model_Website
  117. */
  118. public function getWebsiteByCode($websiteCode)
  119. {
  120. if (is_null($this->_websites)) {
  121. $this->_websites = Mage::app()->getWebsites(true, true);
  122. }
  123. if (isset($this->_websites[$websiteCode])) {
  124. return $this->_websites[$websiteCode];
  125. }
  126. return false;
  127. }
  128. /**
  129. * Retrieve eav entity attribute model
  130. *
  131. * @param string $code
  132. * @return Mage_Eav_Model_Entity_Attribute
  133. */
  134. public function getAttribute($code)
  135. {
  136. if (!isset($this->_attributes[$code])) {
  137. $this->_attributes[$code] = $this->getCustomerModel()->getResource()->getAttribute($code);
  138. }
  139. return $this->_attributes[$code];
  140. }
  141. /**
  142. * Retrieve region id by country code and region name (if exists)
  143. *
  144. * @param string $country
  145. * @param string $region
  146. * @return int
  147. */
  148. public function getRegionId($country, $regionName)
  149. {
  150. if (is_null($this->_regions)) {
  151. $this->_regions = array();
  152. $collection = Mage::getModel('directory/region')
  153. ->getCollection();
  154. foreach ($collection as $region) {
  155. if (!isset($this->_regions[$region->getCountryId()])) {
  156. $this->_regions[$region->getCountryId()] = array();
  157. }
  158. $this->_regions[$region->getCountryId()][$region->getDefaultName()] = $region->getId();
  159. }
  160. }
  161. if (isset($this->_regions[$country][$regionName])) {
  162. return $this->_regions[$country][$regionName];
  163. }
  164. return 0;
  165. }
  166. /**
  167. * Retrieve customer group collection array
  168. *
  169. * @return array
  170. */
  171. public function getCustomerGroups()
  172. {
  173. if (is_null($this->_customerGroups)) {
  174. $this->_customerGroups = array();
  175. $collection = Mage::getModel('customer/group')
  176. ->getCollection()
  177. ->addFieldToFilter('customer_group_id', array('gt'=> 0));
  178. foreach ($collection as $group) {
  179. $this->_customerGroups[$group->getCustomerGroupCode()] = $group->getId();
  180. }
  181. }
  182. return $this->_customerGroups;
  183. }
  184. /**
  185. * Alias at getCustomerGroups()
  186. *
  187. * @return array
  188. */
  189. public function getCustomerGoups()
  190. {
  191. return $this->getCustomerGroups();
  192. }
  193. public function __construct()
  194. {
  195. $this->setVar('entity_type', 'customer/customer');
  196. if (!Mage::registry('Object_Cache_Customer')) {
  197. $this->setCustomer(Mage::getModel('customer/customer'));
  198. }
  199. //$this->setAddress(Mage::getModel('catalog/'))
  200. foreach (Mage::getConfig()->getFieldset('customer_dataflow', 'admin') as $code=>$node) {
  201. if ($node->is('ignore')) {
  202. $this->_ignoreFields[] = $code;
  203. }
  204. if ($node->is('billing')) {
  205. $this->_billingFields[] = 'billing_'.$code;
  206. }
  207. if ($node->is('shipping')) {
  208. $this->_shippingFields[] = 'shipping_'.$code;
  209. }
  210. if ($node->is('billing') && $node->is('shipping')) {
  211. $this->_addressFields[] = $code;
  212. }
  213. if ($node->is('mapped') || $node->is('billing_mapped')) {
  214. $this->_billingMappedFields['billing_'.$code] = $code;
  215. }
  216. if ($node->is('mapped') || $node->is('shipping_mapped')) {
  217. $this->_shippingMappedFields['shipping_'.$code] = $code;
  218. }
  219. if ($node->is('street')) {
  220. $this->_billingStreetFields[] = 'billing_'.$code;
  221. $this->_shippingStreetFields[] = 'shipping_'.$code;
  222. }
  223. if ($node->is('required')) {
  224. $this->_requiredFields[] = $code;
  225. }
  226. if ($node->is('billing_required')) {
  227. $this->_billingRequiredFields[] = 'billing_'.$code;
  228. }
  229. if ($node->is('shipping_required')) {
  230. $this->_shippingRequiredFields[] = 'shipping_'.$code;
  231. }
  232. }
  233. }
  234. public function load()
  235. {
  236. $addressType = $this->getVar('filter/adressType'); //error in key filter addressType
  237. if ($addressType=='both') {
  238. $addressType = array('default_billing','default_shipping');
  239. }
  240. $attrFilterArray = array();
  241. $attrFilterArray ['firstname'] = 'like';
  242. $attrFilterArray ['lastname'] = 'like';
  243. $attrFilterArray ['email'] = 'like';
  244. $attrFilterArray ['group'] = 'eq';
  245. $attrFilterArray ['customer_address/telephone'] = array(
  246. 'type' => 'like',
  247. 'bind' => $addressType
  248. );
  249. $attrFilterArray ['customer_address/postcode'] = array(
  250. 'type' => 'like',
  251. 'bind' => $addressType
  252. );
  253. $attrFilterArray ['customer_address/country'] = array(
  254. 'type' => 'eq',
  255. 'bind' => $addressType
  256. );
  257. $attrFilterArray ['customer_address/region'] = array(
  258. 'type' => 'like',
  259. 'bind' => $addressType
  260. );
  261. $attrFilterArray ['created_at'] = 'datetimeFromTo';
  262. /*
  263. * Fixing date filter from and to
  264. */
  265. if ($var = $this->getVar('filter/created_at/from')) {
  266. $this->setVar('filter/created_at/from', $var . ' 00:00:00');
  267. }
  268. if ($var = $this->getVar('filter/created_at/to')) {
  269. $this->setVar('filter/created_at/to', $var . ' 23:59:59');
  270. }
  271. $attrToDb = array(
  272. 'group' => 'group_id',
  273. 'customer_address/country' => 'customer_address/country_id',
  274. );
  275. // Added store filter
  276. if ($storeId = $this->getStoreId()) {
  277. $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
  278. if ($websiteId) {
  279. $this->_filter[] = array(
  280. 'attribute' => 'website_id',
  281. 'eq' => $websiteId
  282. );
  283. }
  284. }
  285. parent::setFilter($attrFilterArray, $attrToDb);
  286. return parent::load();
  287. }
  288. /**
  289. * Not use :(
  290. */
  291. public function parse()
  292. {
  293. $batchModel = Mage::getSingleton('dataflow/batch');
  294. /* @var $batchModel Mage_Dataflow_Model_Batch */
  295. $batchImportModel = $batchModel->getBatchImportModel();
  296. $importIds = $batchImportModel->getIdCollection();
  297. foreach ($importIds as $importId) {
  298. $batchImportModel->load($importId);
  299. $importData = $batchImportModel->getBatchData();
  300. $this->saveRow($importData);
  301. }
  302. }
  303. public function setCustomer(Mage_Customer_Model_Customer $customer)
  304. {
  305. $id = Mage::objects()->save($customer);
  306. Mage::register('Object_Cache_Customer', $id);
  307. }
  308. public function getCustomer()
  309. {
  310. return Mage::objects()->load(Mage::registry('Object_Cache_Customer'));
  311. }
  312. public function save()
  313. {
  314. $stores = array();
  315. foreach (Mage::getConfig()->getNode('stores')->children() as $storeNode) {
  316. $stores[(int)$storeNode->system->store->id] = $storeNode->getName();
  317. }
  318. $collections = $this->getData();
  319. if ($collections instanceof Mage_Customer_Model_Entity_Customer_Collection) {
  320. $collections = array($collections->getEntity()->getStoreId()=>$collections);
  321. } elseif (!is_array($collections)) {
  322. $this->addException(Mage::helper('customer')->__('No customer collections found'), Mage_Dataflow_Model_Convert_Exception::FATAL);
  323. }
  324. foreach ($collections as $storeId=>$collection) {
  325. $this->addException(Mage::helper('customer')->__('Records for %s store found.', $stores[$storeId]));
  326. if (!$collection instanceof Mage_Customer_Model_Entity_Customer_Collection) {
  327. $this->addException(Mage::helper('customer')->__('Customer collection expected.'), Mage_Dataflow_Model_Convert_Exception::FATAL);
  328. }
  329. try {
  330. $i = 0;
  331. foreach ($collection->getIterator() as $model) {
  332. $new = false;
  333. // if customer is new, create default values first
  334. if (!$model->getId()) {
  335. $new = true;
  336. $model->save();
  337. #Mage::getResourceSingleton('catalog_entity/convert')->addProductToStore($model->getId(), 0);
  338. }
  339. if (!$new || 0!==$storeId) {
  340. // if (0!==$storeId) {
  341. // Mage::getResourceSingleton('catalog_entity/convert')->addProductToStore($model->getId(), $storeId);
  342. // }
  343. $model->save();
  344. }
  345. $i++;
  346. }
  347. $this->addException(Mage::helper('customer')->__("Saved %d record(s)", $i));
  348. } catch (Exception $e) {
  349. if (!$e instanceof Mage_Dataflow_Model_Convert_Exception) {
  350. $this->addException(Mage::helper('customer')->__('An error occurred while saving the collection, aborting. Error: %s', $e->getMessage()),
  351. Mage_Dataflow_Model_Convert_Exception::FATAL);
  352. }
  353. }
  354. }
  355. return $this;
  356. }
  357. /*
  358. * saveRow function for saving each customer data
  359. *
  360. * params args array
  361. * return array
  362. */
  363. public function saveRow($importData)
  364. {
  365. $customer = $this->getCustomerModel();
  366. $customer->setId(null);
  367. if (empty($importData['website'])) {
  368. $message = Mage::helper('customer')->__('Skipping import row, required field "%s" is not defined.', 'website');
  369. Mage::throwException($message);
  370. }
  371. $website = $this->getWebsiteByCode($importData['website']);
  372. if ($website === false) {
  373. $message = Mage::helper('customer')->__('Skipping import row, website "%s" field does not exist.', $importData['website']);
  374. Mage::throwException($message);
  375. }
  376. if (empty($importData['email'])) {
  377. $message = Mage::helper('customer')->__('Skipping import row, required field "%s" is not defined.', 'email');
  378. Mage::throwException($message);
  379. }
  380. $customer->setWebsiteId($website->getId())
  381. ->loadByEmail($importData['email']);
  382. if (!$customer->getId()) {
  383. $customerGroups = $this->getCustomerGroups();
  384. /**
  385. * Check customer group
  386. */
  387. if (empty($importData['group']) || !isset($customerGroups[$importData['group']])) {
  388. $value = isset($importData['group']) ? $importData['group'] : '';
  389. $message = Mage::helper('catalog')->__('Skipping import row, the value "%s" is not valid for the "%s" field.', $value, 'group');
  390. Mage::throwException($message);
  391. }
  392. $customer->setGroupId($customerGroups[$importData['group']]);
  393. foreach ($this->_requiredFields as $field) {
  394. if (!isset($importData[$field])) {
  395. $message = Mage::helper('catalog')->__('Skip import row, required field "%s" for the new customer is not defined.', $field);
  396. Mage::throwException($message);
  397. }
  398. }
  399. $customer->setWebsiteId($website->getId());
  400. if (empty($importData['created_in']) || !$this->getStoreByCode($importData['created_in'])) {
  401. $customer->setStoreId(0);
  402. }
  403. else {
  404. $customer->setStoreId($this->getStoreByCode($importData['created_in'])->getId());
  405. }
  406. if (empty($importData['password_hash'])) {
  407. $customer->setPasswordHash($customer->hashPassword($customer->generatePassword(8)));
  408. }
  409. }
  410. elseif (!empty($importData['group'])) {
  411. $customerGroups = $this->getCustomerGroups();
  412. /**
  413. * Check customer group
  414. */
  415. if (isset($customerGroups[$importData['group']])) {
  416. $customer->setGroupId($customerGroups[$importData['group']]);
  417. }
  418. }
  419. foreach ($this->_ignoreFields as $field) {
  420. if (isset($importData[$field])) {
  421. unset($importData[$field]);
  422. }
  423. }
  424. foreach ($importData as $field => $value) {
  425. if (in_array($field, $this->_billingFields)) {
  426. continue;
  427. }
  428. if (in_array($field, $this->_shippingFields)) {
  429. continue;
  430. }
  431. $attribute = $this->getAttribute($field);
  432. if (!$attribute) {
  433. continue;
  434. }
  435. $isArray = false;
  436. $setValue = $value;
  437. if ($attribute->getFrontendInput() == 'multiselect') {
  438. $value = explode(self::MULTI_DELIMITER, $value);
  439. $isArray = true;
  440. $setValue = array();
  441. }
  442. if ($attribute->usesSource()) {
  443. $options = $attribute->getSource()->getAllOptions(false);
  444. if ($isArray) {
  445. foreach ($options as $item) {
  446. if (in_array($item['label'], $value)) {
  447. $setValue[] = $item['value'];
  448. }
  449. }
  450. }
  451. else {
  452. $setValue = null;
  453. foreach ($options as $item) {
  454. if ($item['label'] == $value) {
  455. $setValue = $item['value'];
  456. }
  457. }
  458. }
  459. }
  460. $customer->setData($field, $setValue);
  461. }
  462. if (isset($importData['is_subscribed'])) {
  463. $customer->setData('is_subscribed', $importData['is_subscribed']);
  464. }
  465. $importBillingAddress = $importShippingAddress = true;
  466. $savedBillingAddress = $savedShippingAddress = false;
  467. /**
  468. * Check Billing address required fields
  469. */
  470. foreach ($this->_billingRequiredFields as $field) {
  471. if (empty($importData[$field])) {
  472. $importBillingAddress = false;
  473. }
  474. }
  475. /**
  476. * Check Sipping address required fields
  477. */
  478. foreach ($this->_shippingRequiredFields as $field) {
  479. if (empty($importData[$field])) {
  480. $importShippingAddress = false;
  481. }
  482. }
  483. $onlyAddress = false;
  484. /**
  485. * Check addresses
  486. */
  487. if ($importBillingAddress && $importShippingAddress) {
  488. $onlyAddress = true;
  489. foreach ($this->_addressFields as $field) {
  490. if (!isset($importData['billing_'.$field]) && !isset($importData['shipping_'.$field])) {
  491. continue;
  492. }
  493. if (!isset($importData['billing_'.$field]) || !isset($importData['shipping_'.$field])) {
  494. $onlyAddress = false;
  495. break;
  496. }
  497. if ($importData['billing_'.$field] != $importData['shipping_'.$field]) {
  498. $onlyAddress = false;
  499. break;
  500. }
  501. }
  502. if ($onlyAddress) {
  503. $importShippingAddress = false;
  504. }
  505. }
  506. /**
  507. * Import billing address
  508. */
  509. if ($importBillingAddress) {
  510. $billingAddress = $this->getBillingAddressModel();
  511. if ($customer->getDefaultBilling()) {
  512. $billingAddress->load($customer->getDefaultBilling());
  513. }
  514. else {
  515. $billingAddress->setData(array());
  516. }
  517. foreach ($this->_billingFields as $field) {
  518. $cleanField = Mage::helper('core/string')->substr($field, 8);
  519. if (isset($importData[$field])) {
  520. $billingAddress->setDataUsingMethod($cleanField, $importData[$field]);
  521. }
  522. elseif (isset($this->_billingMappedFields[$field])
  523. && isset($importData[$this->_billingMappedFields[$field]])) {
  524. $billingAddress->setDataUsingMethod($cleanField, $importData[$this->_billingMappedFields[$field]]);
  525. }
  526. }
  527. $street = array();
  528. foreach ($this->_billingStreetFields as $field) {
  529. if (!empty($importData[$field])) {
  530. $street[] = $importData[$field];
  531. }
  532. }
  533. if ($street) {
  534. $billingAddress->setDataUsingMethod('street', $street);
  535. }
  536. $billingAddress->setCountryId($importData['billing_country']);
  537. $regionName = isset($importData['billing_region']) ? $importData['billing_region'] : '';
  538. if ($regionName) {
  539. $regionId = $this->getRegionId($importData['billing_country'], $regionName);
  540. $billingAddress->setRegionId($regionId);
  541. }
  542. if ($customer->getId()) {
  543. $billingAddress->setCustomerId($customer->getId());
  544. $billingAddress->save();
  545. $customer->setDefaultBilling($billingAddress->getId());
  546. if ($onlyAddress) {
  547. $customer->setDefaultShipping($billingAddress->getId());
  548. }
  549. $savedBillingAddress = true;
  550. }
  551. }
  552. /**
  553. * Import shipping address
  554. */
  555. if ($importShippingAddress) {
  556. $shippingAddress = $this->getShippingAddressModel();
  557. if ($customer->getDefaultShipping() && $customer->getDefaultBilling() != $customer->getDefaultShipping()) {
  558. $shippingAddress->load($customer->getDefaultShipping());
  559. }
  560. else {
  561. $shippingAddress->setData(array());
  562. }
  563. foreach ($this->_shippingFields as $field) {
  564. $cleanField = Mage::helper('core/string')->substr($field, 9);
  565. if (isset($importData[$field])) {
  566. $shippingAddress->setDataUsingMethod($cleanField, $importData[$field]);
  567. }
  568. elseif (isset($this->_shippingMappedFields[$field])
  569. && isset($importData[$this->_shippingMappedFields[$field]])) {
  570. $shippingAddress->setDataUsingMethod($cleanField, $importData[$this->_shippingMappedFields[$field]]);
  571. }
  572. }
  573. $street = array();
  574. foreach ($this->_shippingStreetFields as $field) {
  575. if (!empty($importData[$field])) {
  576. $street[] = $importData[$field];
  577. }
  578. }
  579. if ($street) {
  580. $shippingAddress->setDataUsingMethod('street', $street);
  581. }
  582. $shippingAddress->setCountryId($importData['shipping_country']);
  583. $regionName = isset($importData['shipping_region']) ? $importData['shipping_region'] : '';
  584. if ($regionName) {
  585. $regionId = $this->getRegionId($importData['shipping_country'], $regionName);
  586. $shippingAddress->setRegionId($regionId);
  587. }
  588. if ($customer->getId()) {
  589. $shippingAddress->setCustomerId($customer->getId());
  590. $shippingAddress->save();
  591. $customer->setDefaultShipping($shippingAddress->getId());
  592. $savedShippingAddress = true;
  593. }
  594. }
  595. $customer->setImportMode(true);
  596. $customer->save();
  597. $saveCustomer = false;
  598. if ($importBillingAddress && !$savedBillingAddress) {
  599. $saveCustomer = true;
  600. $billingAddress->setCustomerId($customer->getId());
  601. $billingAddress->save();
  602. $customer->setDefaultBilling($billingAddress->getId());
  603. if ($onlyAddress) {
  604. $customer->setDefaultShipping($billingAddress->getId());
  605. }
  606. }
  607. if ($importShippingAddress && !$savedShippingAddress) {
  608. $saveCustomer = true;
  609. $shippingAddress->setCustomerId($customer->getId());
  610. $shippingAddress->save();
  611. $customer->setDefaultShipping($shippingAddress->getId());
  612. }
  613. if ($saveCustomer) {
  614. $customer->save();
  615. }
  616. return $this;
  617. }
  618. public function getCustomerId()
  619. {
  620. return $this->_customerId;
  621. }
  622. /* ########### THE CODE BELOW AT THIS METHOD IS NOT USED ############# */
  623. public function saveRow__OLD()
  624. {
  625. $mem = memory_get_usage(); $origMem = $mem; $memory = $mem;
  626. $customer = $this->getCustomer();
  627. @set_time_limit(240);
  628. $row = $args;
  629. $newMem = memory_get_usage(); $memory .= ', '.($newMem-$mem); $mem = $newMem;
  630. $customer->importFromTextArray($row);
  631. if (!$customer->getData()) {
  632. return;
  633. }
  634. $newMem = memory_get_usage(); $memory .= ', '.($newMem-$mem); $mem = $newMem;
  635. try {
  636. $customer->save();
  637. $this->_customerId = $customer->getId();
  638. $customer->unsetData();
  639. $customer->cleanAllAddresses();
  640. $customer->unsetSubscription();
  641. $newMem = memory_get_usage(); $memory .= ', '.($newMem-$mem); $mem = $newMem;
  642. } catch (Exception $e) {
  643. }
  644. unset($row);
  645. return array('memory'=>$memory);
  646. }
  647. }