@@ -113,9 +113,9 @@ public function save(\PDP\Integration\Api\Data\PdpDesignItemInterface $pdpDesign
113
113
->setMessage (nl2br ($ e ->getMessage ()));
114
114
return $ reponse ;
115
115
}
116
- $ dataGuestDesign = $ modelGuestDesign ->loadByCustomerId ($ customerId );
117
- if ($ dataGuestDesign ->getEntityId ()) {
118
- $ dataItemVal = unserialize ($ dataGuestDesign ->getItemValue ());
116
+ $ dataGuestDesignData = $ modelGuestDesign ->loadByCustomerId ($ customerId );
117
+ if ($ dataGuestDesignData ->getEntityId ()) {
118
+ $ dataItemVal = unserialize ($ dataGuestDesignData ->getItemValue ());
119
119
if (isset ($ _dataItemVal )) {
120
120
foreach ($ _dataItemVal as $ _item ) {
121
121
$ dataItemVal [] = $ _item ;
@@ -131,7 +131,7 @@ public function save(\PDP\Integration\Api\Data\PdpDesignItemInterface $pdpDesign
131
131
if (!$ update ) {
132
132
$ dataItemVal [] = $ itemValue ;
133
133
}
134
- $ dataGuestDesign ->setItemValue (serialize ($ dataItemVal ))->save ();
134
+ $ dataGuestDesignData ->setItemValue (serialize ($ dataItemVal ))->save ();
135
135
}
136
136
} catch (\Magento \Framework \Exception \LocalizedException $ e ) {
137
137
$ reponse ->setStatus (false )
@@ -142,9 +142,9 @@ public function save(\PDP\Integration\Api\Data\PdpDesignItemInterface $pdpDesign
142
142
} else {
143
143
if ($ customerId ) {
144
144
try {
145
- $ dataGuestDesign = $ modelGuestDesign ->loadByCustomerId ($ customerId );
146
- if ($ dataGuestDesign ->getEntityId ()) {
147
- $ dataItemVal = unserialize ($ dataGuestDesign ->getItemValue ());
145
+ $ dataGuestDesignData = $ modelGuestDesign ->loadByCustomerId ($ customerId );
146
+ if ($ dataGuestDesignData ->getEntityId ()) {
147
+ $ dataItemVal = unserialize ($ dataGuestDesignData ->getItemValue ());
148
148
$ update = false ;
149
149
foreach ($ dataItemVal as $ __item ) {
150
150
if ($ __item ['product_id ' ] == $ itemValue ['product_id ' ] && $ __item ['pdp_product_id ' ] == $ itemValue ['pdp_product_id ' ] && $ __item ['design_id ' ] == $ itemValue ['design_id ' ]) {
@@ -156,7 +156,20 @@ public function save(\PDP\Integration\Api\Data\PdpDesignItemInterface $pdpDesign
156
156
$ dataItemVal [] = $ itemValue ;
157
157
}
158
158
159
- $ dataGuestDesign ->setItemValue (serialize ($ dataItemVal ))->save ();
159
+ $ dataGuestDesignData ->setItemValue (serialize ($ dataItemVal ))->save ();
160
+ } else {
161
+ try {
162
+ $ dataGuestDesign ['item_value ' ] = serialize ([$ itemValue ]);
163
+ $ dataGuestDesign ['customer_is_guest ' ] = 0 ;
164
+ $ dataGuestDesign ['customer_id ' ] = $ customerId ;
165
+ $ modelGuestDesign ->addData ($ dataGuestDesign )->save ();
166
+ $ pdpGuestDesignId = $ modelGuestDesign ->getEntityId ();
167
+ $ this ->_pdpIntegrationSession ->setPdpDesignId ($ pdpGuestDesignId );
168
+ } catch (\Magento \Framework \Exception \LocalizedException $ e ) {
169
+ $ reponse ->setStatus (false )
170
+ ->setMessage (nl2br ($ e ->getMessage ()));
171
+ return $ reponse ;
172
+ }
160
173
}
161
174
} catch (\Magento \Framework \Exception \LocalizedException $ e ) {
162
175
$ reponse ->setStatus (false )
@@ -169,8 +182,8 @@ public function save(\PDP\Integration\Api\Data\PdpDesignItemInterface $pdpDesign
169
182
if ($ this ->_pdpIntegrationSession ->getPdpDesignId ()) {
170
183
$ pdpGuestDesignId = $ this ->_pdpIntegrationSession ->getPdpDesignId ();
171
184
try {
172
- $ dataGuestDesign = $ modelGuestDesign ->load ($ pdpGuestDesignId );
173
- $ dataItemVal = unserialize ($ dataGuestDesign ->getItemValue ());
185
+ $ dataGuestDesignData = $ modelGuestDesign ->load ($ pdpGuestDesignId );
186
+ $ dataItemVal = unserialize ($ dataGuestDesignData ->getItemValue ());
174
187
$ update = false ;
175
188
foreach ($ dataItemVal as $ __item ) {
176
189
if ($ __item ['product_id ' ] == $ itemValue ['product_id ' ] && $ __item ['pdp_product_id ' ] == $ itemValue ['pdp_product_id ' ] && $ __item ['design_id ' ] == $ itemValue ['design_id ' ]) {
@@ -181,7 +194,7 @@ public function save(\PDP\Integration\Api\Data\PdpDesignItemInterface $pdpDesign
181
194
if (!$ update ) {
182
195
$ dataItemVal [] = $ itemValue ;
183
196
}
184
- $ dataGuestDesign ->setItemValue (serialize ($ dataItemVal ))->save ();
197
+ $ dataGuestDesignData ->setItemValue (serialize ($ dataItemVal ))->save ();
185
198
} catch (\Magento \Framework \Exception \LocalizedException $ e ) {
186
199
$ reponse ->setStatus (false )
187
200
->setMessage (nl2br ($ e ->getMessage ()));
0 commit comments