Completed
Push — master ( a18731...e2e070 )
by
unknown
99:54 queued 47:45
created

Cart::getStoreCurrencyCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\Common\Collections\ArrayCollection;
8
9
use Oro\Bundle\OrganizationBundle\Entity\Organization;
10
use Oro\Bundle\UserBundle\Entity\User;
11
use Oro\Bundle\LocaleBundle\Model\FirstNameInterface;
12
use Oro\Bundle\LocaleBundle\Model\LastNameInterface;
13
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config;
14
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField;
15
16
use OroCRM\Bundle\MagentoBundle\Model\ExtendCart;
17
use OroCRM\Bundle\SalesBundle\Entity\Opportunity;
18
use OroCRM\Bundle\ChannelBundle\Model\ChannelAwareInterface;
19
20
/**
21
 * @SuppressWarnings(PHPMD.ExcessivePublicCount)
22
 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
23
 * @SuppressWarnings(PHPMD.TooManyFields)
24
 *
25
 * @package OroCRM\Bundle\OroCRMMagentoBundle\Entity
26
 * @ORM\Entity(repositoryClass="OroCRM\Bundle\MagentoBundle\Entity\Repository\CartRepository")
27
 * @ORM\HasLifecycleCallbacks
28
 * @ORM\Table(name="orocrm_magento_cart",
29
 *  indexes={
30
 *      @ORM\Index(name="magecart_origin_idx", columns={"origin_id"}),
31
 *      @ORM\Index(name="magecart_updated_idx",columns={"updatedAt"})
32
 *  },
33
 *  uniqueConstraints={
34
 *      @ORM\UniqueConstraint(name="unq_cart_origin_id_channel_id", columns={"origin_id", "channel_id"})
35
 *  }
36
 * )
37
 * @Config(
38
 *      routeView="orocrm_magento_cart_view",
39
 *      defaultValues={
40
 *          "entity"={
41
 *              "icon"="icon-shopping-cart"
42
 *          },
43
 *          "ownership"={
44
 *              "owner_type"="USER",
45
 *              "owner_field_name"="owner",
46
 *              "owner_column_name"="user_owner_id",
47
 *              "organization_field_name"="organization",
48
 *              "organization_column_name"="organization_id"
49
 *          },
50
 *          "security"={
51
 *              "type"="ACL",
52
 *              "group_name"="",
53
 *              "category"="sales_data"
54
 *          },
55
 *          "form"={
56
 *              "grid_name"="magento-cart-grid",
57
 *          },
58
 *          "workflow"={
59
 *              "active_workflows"={"b2c_flow_abandoned_shopping_cart"}
60
 *          },
61
 *          "grid"={
62
 *              "default"="magento-cart-grid",
63
 *              "context"="magento-cart-for-context-grid"
64
 *          },
65
 *          "tag"={
66
 *              "enabled"=true
67
 *          }
68
 *      }
69
 * )
70
 */
71
class Cart extends ExtendCart implements
72
    ChannelAwareInterface,
73
    FirstNameInterface,
74
    LastNameInterface,
75
    OriginAwareInterface,
76
    IntegrationAwareInterface
77
{
78
    use IntegrationEntityTrait, OriginTrait, NamesAwareTrait, ChannelEntityTrait;
79
80
    /**
81
     * @var CartItem[]|Collection
82
     *
83
     * @ORM\OneToMany(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\CartItem",
84
     *     mappedBy="cart", cascade={"all"}, orphanRemoval=true
85
     * )
86
     * @ORM\OrderBy({"originId" = "DESC"})
87
     * @ConfigField(
88
     *      defaultValues={
89
     *          "importexport"={
90
     *              "full"=true
91
     *          }
92
     *      }
93
     * )
94
     */
95
    protected $cartItems;
96
97
    /**
98
     * @ORM\ManyToOne(targetEntity="Customer", inversedBy="carts")
99
     * @ORM\JoinColumn(name="customer_id", referencedColumnName="id", onDelete="CASCADE")
100
     */
101
    protected $customer;
102
103
    /**
104
     * @var Store
105
     *
106
     * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\Store")
107
     * @ORM\JoinColumn(name="store_id", referencedColumnName="id", onDelete="SET NULL")
108
     * @ConfigField(
109
     *      defaultValues={
110
     *          "importexport"={
111
     *              "full"=false
112
     *          }
113
     *      }
114
     * )
115
     */
116
    protected $store;
117
118
    /**
119
     * Total items qty
120
     *
121
     * @var float
122
     *
123
     * @ORM\Column(name="items_qty", type="float")
124
     */
125
    protected $itemsQty;
126
127
    /**
128
     * Items count
129
     *
130
     * @var integer
131
     *
132
     * @ORM\Column(name="items_count", type="integer", options={"unsigned"=true})
133
     */
134
    protected $itemsCount;
135
136
    /**
137
     * @var string
138
     *
139
     * @ORM\Column(name="base_currency_code", type="string", length=32, nullable=false)
140
     */
141
    protected $baseCurrencyCode;
142
143
    /**
144
     * @var string
145
     *
146
     * @ORM\Column(name="store_currency_code", type="string", length=32, nullable=false)
147
     */
148
    protected $storeCurrencyCode;
149
150
    /**
151
     * @var string
152
     *
153
     * @ORM\Column(name="quote_currency_code", type="string", length=32, nullable=false)
154
     */
155
    protected $quoteCurrencyCode;
156
157
    /**
158
     * @var float
159
     *
160
     * @ORM\Column(name="store_to_base_rate", type="float", nullable=false)
161
     */
162
    protected $storeToBaseRate;
163
164
    /**
165
     * @var float
166
     *
167
     * @ORM\Column(name="store_to_quote_rate", type="float", nullable=true)
168
     */
169
    protected $storeToQuoteRate;
170
171
    /**
172
     * @var string
173
     *
174
     * @ORM\Column(name="email", type="string", length=255, nullable=true)
175
     * @ConfigField(
176
     *      defaultValues={
177
     *          "entity"={
178
     *              "contact_information"="email"
179
     *          }
180
     *      }
181
     * )
182
     */
183
    protected $email;
184
185
    /**
186
     * @var string
187
     *
188
     * @ORM\Column(name="gift_message", type="string", length=255, nullable=true)
189
     */
190
    protected $giftMessage;
191
192
    /**
193
     * @var float
194
     *
195
     * @ORM\Column(name="is_guest", type="boolean")
196
     */
197
    protected $isGuest;
198
199
    /**
200
     * @var CartAddress $shippingAddress
201
     *
202
     * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\CartAddress", cascade={"persist", "remove"})
203
     * @ORM\JoinColumn(name="shipping_address_id", referencedColumnName="id", onDelete="SET NULL")
204
     * @ConfigField(
205
     *      defaultValues={
206
     *          "importexport"={
207
     *              "full"=true
208
     *          }
209
     *      }
210
     * )
211
     */
212
    protected $shippingAddress;
213
214
    /**
215
     * @var CartAddress $billingAddress
216
     *
217
     * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\CartAddress", cascade={"persist", "remove"})
218
     * @ORM\JoinColumn(name="billing_address_id", referencedColumnName="id", onDelete="SET NULL")
219
     * @ConfigField(
220
     *      defaultValues={
221
     *          "importexport"={
222
     *              "full"=true
223
     *          }
224
     *      }
225
     * )
226
     */
227
    protected $billingAddress;
228
229
    /**
230
     * @var string
231
     *
232
     * @ORM\Column(name="payment_details", type="string", length=255, nullable=true)
233
     */
234
    protected $paymentDetails;
235
236
    /**
237
     * @var CartStatus
238
     *
239
     * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\CartStatus")
240
     * @ORM\JoinColumn(name="status_name", referencedColumnName="name", onDelete="SET NULL")
241
     * @ConfigField(
242
     *      defaultValues={
243
     *          "importexport"={
244
     *              "full"=false
245
     *          }
246
     *      }
247
     * )
248
     */
249
    protected $status;
250
251
    /**
252
     * @var Opportunity
253
     *
254
     * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\SalesBundle\Entity\Opportunity")
255
     * @ORM\JoinColumn(name="opportunity_id", referencedColumnName="id", onDelete="SET NULL")
256
     */
257
    protected $opportunity;
258
259
    /**
260
     * @var string
261
     *
262
     * @ORM\Column(name="notes", type="text", nullable=true)
263
     */
264
    protected $notes;
265
266
    /**
267
     * @var string
268
     *
269
     * @ORM\Column(name="status_message", type="string", length=255, nullable=true)
270
     */
271
    protected $statusMessage;
272
273
    /**
274
     * @var User
275
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User")
276
     * @ORM\JoinColumn(name="user_owner_id", referencedColumnName="id", onDelete="SET NULL")
277
     */
278
    protected $owner;
279
280
    /**
281
     * @var Organization
282
     *
283
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization")
284
     * @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL")
285
     */
286
    protected $organization;
287
288
    /**
289
     * @var \DateTime
290
     *
291
     * @ORM\Column(type="datetime", name="imported_at", nullable=true)
292
     */
293
    protected $importedAt;
294
295
    /**
296
     * @var \DateTime
297
     *
298
     * @ORM\Column(type="datetime", name="synced_at", nullable=true)
299
     */
300
    protected $syncedAt;
301
302
    public function __construct()
303
    {
304
        parent::__construct();
305
306
        $this->status    = new CartStatus('open');
307
        $this->cartItems = new ArrayCollection();
308
    }
309
310
    /**
311
     * @return CartItem[]|Collection
312
     */
313
    public function getCartItems()
314
    {
315
        return $this->cartItems;
316
    }
317
318
    /**
319
     * @param CartItem[]|Collection $cartItems
320
     */
321
    public function setCartItems(Collection $cartItems)
322
    {
323
        $this->cartItems = $cartItems;
324
    }
325
326
    /**
327
     * @param Store $store
328
     */
329
    public function setStore($store)
330
    {
331
        $this->store = $store;
332
    }
333
334
    /**
335
     * @return Store
336
     */
337
    public function getStore()
338
    {
339
        return $this->store;
340
    }
341
342
    /**
343
     * @return Customer
344
     */
345
    public function getCustomer()
346
    {
347
        return $this->customer;
348
    }
349
350
    /**
351
     * @param Customer|null $customer
352
     *
353
     * @return Cart
354
     */
355
    public function setCustomer(Customer $customer = null)
356
    {
357
        $this->customer = $customer;
358
359
        return $this;
360
    }
361
362
    /**
363
     * @param CartAddress $shippingAddress
364
     *
365
     * @return Cart
366
     */
367
    public function setShippingAddress(CartAddress $shippingAddress = null)
368
    {
369
        $this->shippingAddress = $shippingAddress;
370
371
        return $this;
372
    }
373
374
    /**
375
     * @param CartAddress $billingAddress
376
     *
377
     * @return Cart
378
     */
379
    public function setBillingAddress(CartAddress $billingAddress = null)
380
    {
381
        $this->billingAddress = $billingAddress;
382
383
        return $this;
384
    }
385
386
    /**
387
     * @return CartAddress
388
     */
389
    public function getBillingAddress()
390
    {
391
        return $this->billingAddress;
392
    }
393
394
    /**
395
     * @return CartAddress
396
     */
397
    public function getShippingAddress()
398
    {
399
        return $this->shippingAddress;
400
    }
401
402
    /**
403
     * @return string
404
     */
405
    public function getEmail()
406
    {
407
        return $this->email;
408
    }
409
410
    /**
411
     * @param string $email
412
     *
413
     * @return Cart
414
     */
415
    public function setEmail($email)
416
    {
417
        $this->email = $email;
418
419
        return $this;
420
    }
421
422
    /**
423
     * @return float
424
     */
425
    public function getItemsQty()
426
    {
427
        return $this->itemsQty;
428
    }
429
430
    /**
431
     * @param float $itemsQty
432
     *
433
     * @return Cart
434
     */
435
    public function setItemsQty($itemsQty)
436
    {
437
        $this->itemsQty = $itemsQty;
438
439
        return $this;
440
    }
441
442
    /**
443
     * @return float
444
     */
445
    public function getSubTotal()
446
    {
447
        return $this->subTotal;
448
    }
449
450
    /**
451
     * @return string
452
     */
453
    public function getQuoteCurrencyCode()
454
    {
455
        return $this->quoteCurrencyCode;
456
    }
457
458
    /**
459
     * @param string $quoteCurrencyCode
460
     *
461
     * @return Cart
462
     */
463
    public function setQuoteCurrencyCode($quoteCurrencyCode)
464
    {
465
        $this->quoteCurrencyCode = $quoteCurrencyCode;
466
467
        return $this;
468
    }
469
470
    /**
471
     * @param string $paymentDetails
472
     */
473
    public function setPaymentDetails($paymentDetails)
474
    {
475
        $this->paymentDetails = $paymentDetails;
476
    }
477
478
    /**
479
     * @return string
480
     */
481
    public function getPaymentDetails()
482
    {
483
        return $this->paymentDetails;
484
    }
485
486
    /**
487
     * @param CartStatus $status
488
     *
489
     * @return Cart
490
     */
491
    public function setStatus($status)
492
    {
493
        $this->status = $status;
494
495
        return $this;
496
    }
497
498
    /**
499
     * @return CartStatus
500
     */
501
    public function getStatus()
502
    {
503
        return $this->status;
504
    }
505
506
    /**
507
     * @param string $baseCurrencyCode
508
     *
509
     * @return Cart
510
     */
511
    public function setBaseCurrencyCode($baseCurrencyCode)
512
    {
513
        $this->baseCurrencyCode = $baseCurrencyCode;
514
515
        return $this;
516
    }
517
518
    /**
519
     * @return string
520
     */
521
    public function getBaseCurrencyCode()
522
    {
523
        return $this->baseCurrencyCode;
524
    }
525
526
    /**
527
     * @param string $giftMessage
528
     *
529
     * @return Cart
530
     */
531
    public function setGiftMessage($giftMessage)
532
    {
533
        $this->giftMessage = $giftMessage;
534
535
        return $this;
536
    }
537
538
    /**
539
     * @return string
540
     */
541
    public function getGiftMessage()
542
    {
543
        return $this->giftMessage;
544
    }
545
546
    /**
547
     * @param float $isGuest
548
     *
549
     * @return Cart
550
     */
551
    public function setIsGuest($isGuest)
552
    {
553
        $this->isGuest = $isGuest;
554
555
        return $this;
556
    }
557
558
    /**
559
     * @return float
560
     */
561
    public function getIsGuest()
562
    {
563
        return $this->isGuest;
564
    }
565
566
    /**
567
     * @param int $itemsCount
568
     *
569
     * @return Cart
570
     */
571
    public function setItemsCount($itemsCount)
572
    {
573
        $this->itemsCount = $itemsCount;
574
575
        return $this;
576
    }
577
578
    /**
579
     * @return int
580
     */
581
    public function getItemsCount()
582
    {
583
        return $this->itemsCount;
584
    }
585
586
    /**
587
     * @param string $storeCurrencyCode
588
     *
589
     * @return Cart
590
     */
591
    public function setStoreCurrencyCode($storeCurrencyCode)
592
    {
593
        $this->storeCurrencyCode = $storeCurrencyCode;
594
595
        return $this;
596
    }
597
598
    /**
599
     * @return string
600
     */
601
    public function getStoreCurrencyCode()
602
    {
603
        return $this->storeCurrencyCode;
604
    }
605
606
    /**
607
     * @param float $storeToBaseRate
608
     *
609
     * @return Cart
610
     */
611
    public function setStoreToBaseRate($storeToBaseRate)
612
    {
613
        $this->storeToBaseRate = $storeToBaseRate;
614
615
        return $this;
616
    }
617
618
    /**
619
     * @return float
620
     */
621
    public function getStoreToBaseRate()
622
    {
623
        return $this->storeToBaseRate;
624
    }
625
626
    /**
627
     * @param float $storeToQuoteRate
628
     *
629
     * @return Cart
630
     */
631
    public function setStoreToQuoteRate($storeToQuoteRate)
632
    {
633
        $this->storeToQuoteRate = $storeToQuoteRate;
634
635
        return $this;
636
    }
637
638
    /**
639
     * @return float
640
     */
641
    public function getStoreToQuoteRate()
642
    {
643
        return $this->storeToQuoteRate;
644
    }
645
646
    /**
647
     * @param Opportunity $opportunity
648
     *
649
     * @return Cart
650
     */
651
    public function setOpportunity($opportunity)
652
    {
653
        $this->opportunity = $opportunity;
654
655
        return $this;
656
    }
657
658
    /**
659
     * @return Opportunity
660
     */
661
    public function getOpportunity()
662
    {
663
        return $this->opportunity;
664
    }
665
666
    /**
667
     * @param string $notes
668
     *
669
     * @return Cart
670
     */
671
    public function setNotes($notes)
672
    {
673
        $this->notes = $notes;
674
        return $this;
675
    }
676
677
    /**
678
     * @return string
679
     */
680
    public function getNotes()
681
    {
682
        return $this->notes;
683
    }
684
685
    /**
686
     * Pre persist event listener
687
     *
688
     * @ORM\PrePersist
689
     */
690
    public function beforeSave()
691
    {
692
        $this->updateNames();
693
    }
694
695
    /**
696
     * Pre update event handler
697
     *
698
     * @ORM\PreUpdate
699
     */
700
    public function doPreUpdate()
701
    {
702
        $this->updateNames();
703
    }
704
705
    /**
706
     * @param string $statusMessage
707
     */
708
    public function setStatusMessage($statusMessage)
709
    {
710
        $this->statusMessage = $statusMessage;
711
    }
712
713
    /**
714
     * @return string
715
     */
716
    public function getStatusMessage()
717
    {
718
        return $this->statusMessage;
719
    }
720
721
    /**
722
     * @return User
723
     */
724
    public function getOwner()
725
    {
726
        return $this->owner;
727
    }
728
729
    /**
730
     * @param User $user
731
     */
732
    public function setOwner(User $user)
733
    {
734
        $this->owner = $user;
735
    }
736
737
    /**
738
     * Set organization
739
     *
740
     * @param Organization $organization
741
     * @return Cart
742
     */
743
    public function setOrganization(Organization $organization = null)
744
    {
745
        $this->organization = $organization;
746
747
        return $this;
748
    }
749
750
    /**
751
     * Get organization
752
     *
753
     * @return Organization
754
     */
755
    public function getOrganization()
756
    {
757
        return $this->organization;
758
    }
759
760
    /**
761
     * @return \DateTime
762
     */
763
    public function getSyncedAt()
764
    {
765
        return $this->syncedAt;
766
    }
767
768
    /**
769
     * @param \DateTime $syncedAt
770
     * @return Customer
771
     */
772
    public function setSyncedAt(\DateTime $syncedAt)
773
    {
774
        $this->syncedAt = $syncedAt;
775
776
        return $this;
777
    }
778
779
    /**
780
     * @return \DateTime
781
     */
782
    public function getImportedAt()
783
    {
784
        return $this->importedAt;
785
    }
786
787
    /**
788
     * @param \DateTime $importedAt
789
     * @return Customer
790
     */
791
    public function setImportedAt(\DateTime $importedAt)
792
    {
793
        $this->importedAt = $importedAt;
794
795
        return $this;
796
    }
797
798
    /**
799
     * @return string
800
     */
801
    public function __toString()
802
    {
803
        return (string)$this->getId();
804
    }
805
}
806