16
16
use Magento \Framework \Exception \LocalizedException ;
17
17
use Magento \Newsletter \Model \Subscriber ;
18
18
use Magento \Store \Model \StoreManagerInterface ;
19
+ use Magmodules \Reloadify \Api \Log \RepositoryInterface as LogRepository ;
19
20
20
21
/**
21
22
* Profiles web API service class
@@ -55,6 +56,10 @@ class Profiles
55
56
* @var AddressRepository
56
57
*/
57
58
private $ addressRepository ;
59
+ /**
60
+ * @var LogRepository
61
+ */
62
+ private $ logRepository ;
58
63
59
64
/**
60
65
* Profiles constructor.
@@ -72,14 +77,16 @@ public function __construct(
72
77
CustomerRepositoryInterface $ customerRepository ,
73
78
SearchCriteriaBuilder $ searchCriteriaBuilder ,
74
79
CustomerResource $ customerResource ,
75
- AddressRepository $ addressRepository
80
+ AddressRepository $ addressRepository ,
81
+ LogRepository $ logRepository
76
82
) {
77
83
$ this ->subscriber = $ subscriber ;
78
84
$ this ->storeManager = $ storeManager ;
79
85
$ this ->customerRepository = $ customerRepository ;
80
86
$ this ->searchCriteriaBuilder = $ searchCriteriaBuilder ;
81
87
$ this ->customerResource = $ customerResource ;
82
88
$ this ->addressRepository = $ addressRepository ;
89
+ $ this ->logRepository = $ logRepository ;
83
90
}
84
91
85
92
/**
@@ -108,19 +115,23 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
108
115
];
109
116
110
117
if ($ billingId = $ customer ->getDefaultBilling ()) {
111
- $ billing = $ this ->addressRepository ->getById ((int )$ billingId );
112
- $ mainData += [
113
- "city " => $ billing ->getCity (),
114
- "province " => $ billing ->getRegion ()->getRegion (),
115
- "street " => implode (', ' , $ billing ->getStreet ()),
116
- "zipcode " => $ billing ->getPostcode (),
117
- "country_code " => $ billing ->getCountryId (),
118
- "first_name " => $ billing ->getFirstname (),
119
- "middle_name " => $ billing ->getMiddlename (),
120
- "last_name " => $ billing ->getLastname (),
121
- "telephone " => $ billing ->getTelephone (),
122
- "company_name " => $ billing ->getCompany ()
123
- ];
118
+ try {
119
+ $ billing = $ this ->addressRepository ->getById ((int )$ billingId );
120
+ $ mainData += [
121
+ "city " => $ billing ->getCity (),
122
+ "province " => $ billing ->getRegion ()->getRegion (),
123
+ "street " => implode (', ' , $ billing ->getStreet ()),
124
+ "zipcode " => $ billing ->getPostcode (),
125
+ "country_code " => $ billing ->getCountryId (),
126
+ "first_name " => $ billing ->getFirstname (),
127
+ "middle_name " => $ billing ->getMiddlename (),
128
+ "last_name " => $ billing ->getLastname (),
129
+ "telephone " => $ billing ->getTelephone (),
130
+ "company_name " => $ billing ->getCompany ()
131
+ ];
132
+ } catch (\Exception $ e ) {
133
+ $ this ->logRepository ->addErrorLog ('get profiles ' , $ e ->getMessage ());
134
+ }
124
135
}
125
136
126
137
$ data [] = $ mainData ;
0 commit comments