Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezproductcollection.php
Go to the documentation of this file.
1 <?php
15 class eZProductCollection extends eZPersistentObject
16 {
17 static function definition()
18 {
19 return array( "fields" => array( "id" => array( 'name' => 'ID',
20 'datatype' => 'integer',
21 'default' => 0,
22 'required' => true ),
23 "created" => array( 'name' => "Created",
24 'datatype' => 'integer',
25 'default' => 0,
26 'required' => true ),
27 'currency_code' => array( 'name' => 'CurrencyCode',
28 'datatype' => 'string',
29 'default' => '',
30 'required' => true ) ),
31 "keys" => array( "id" ),
32 "increment_key" => "id",
33 "class_name" => "eZProductCollection",
34 "name" => "ezproductcollection" );
35 }
36
42 static function create( )
43 {
44 $row = array( "created" => time() );
45 return new eZProductCollection( $row );
46 }
47
52 function __clone()
53 {
54 $this->setAttribute( 'id', null );
55 }
56
64 function copy()
65 {
66 $collection = clone $this;
67
68 $db = eZDB::instance();
69 $db->begin();
70 $collection->store();
71
72 $oldItems = $this->itemList();
73 foreach ( $oldItems as $oldItem )
74 {
75 $item = $oldItem->copy( $collection->attribute( 'id' ) );
76 }
77 $db->commit();
78 return $collection;
79 }
80
90 static function fetch( $productCollectionID, $asObject = true )
91 {
92 return eZPersistentObject::fetchObject( eZProductCollection::definition(),
93 null,
94 array( 'id' => $productCollectionID ),
95 $asObject );
96 }
97
106 function itemList( $asObject = true )
107 {
108 return eZPersistentObject::fetchObjectList( eZProductCollectionItem::definition(),
109 null, array( "productcollection_id" => $this->ID ),
110 null,
111 null,
112 $asObject );
113 }
114
115 static function verify( $id )
116 {
117 $invalidItemArray = array();
118 $collection = eZProductCollection::fetch( $id );
119 if ( !is_object( $collection ) )
120 return $invalidItemArray;
121
122 $currency = $collection->attribute( 'currency_code' );
123 $productItemList = eZPersistentObject::fetchObjectList( eZProductCollectionItem::definition(),
124 null, array( "productcollection_id" => $id ),
125 null,
126 null,
127 true );
128 $isValid = true;
129
130 foreach ( $productItemList as $productItem )
131 {
132 if ( !$productItem->verify( $currency ) )
133 {
134 $invalidItemArray[] = $productItem;
135 $isValid = false;
136 }
137 }
138 if ( !$isValid )
139 {
140 return $invalidItemArray;
141 }
142 return $isValid;
143 }
144
153 static function cleanupList( $productCollectionIDList )
154 {
155 $db = eZDB::instance();
156 $db->begin();
157
158 // Purge shipping information associated with product collections being removed.
159 foreach ( $productCollectionIDList as $productCollectionID )
160 eZShippingManager::purgeShippingInfo( $productCollectionID );
161
162 eZProductCollectionItem::cleanupList( $productCollectionIDList );
163 $where = $db->generateSQLINStatement( $productCollectionIDList, 'id', false, false, 'int' );
164 $db->query( "DELETE FROM ezproductcollection WHERE {$where}" );
165 $db->commit();
166 }
167 }
168
169 ?>
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\setAttribute
setAttribute( $attr, $val)
Definition: ezpersistentobject.php:1374
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
eZProductCollectionItem\definition
static definition()
Definition: ezproductcollectionitem.php:21
eZProductCollectionItem\cleanupList
static cleanupList( $productCollectionIDList)
Definition: ezproductcollectionitem.php:277
eZProductCollection
Definition: ezproductcollection.php:16
eZProductCollection\copy
copy()
Definition: ezproductcollection.php:64
eZProductCollection\cleanupList
static cleanupList( $productCollectionIDList)
Definition: ezproductcollection.php:153
eZProductCollection\itemList
itemList( $asObject=true)
Definition: ezproductcollection.php:106
eZProductCollection\create
static create()
Definition: ezproductcollection.php:42
eZProductCollection\verify
static verify( $id)
Definition: ezproductcollection.php:115
eZProductCollection\definition
static definition()
Definition: ezproductcollection.php:17
eZProductCollection\__clone
__clone()
Definition: ezproductcollection.php:52
eZProductCollection\fetch
static fetch( $productCollectionID, $asObject=true)
Definition: ezproductcollection.php:90
eZShippingManager\purgeShippingInfo
static purgeShippingInfo( $productCollectionID)
Definition: ezshippingmanager.php:102
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.