File tree Expand file tree Collapse file tree 6 files changed +22
-11
lines changed
main/java/com/adobe/cq/commerce/core/components/internal/models/v1
java/com/adobe/cq/commerce/core/components/internal/models/v1 Expand file tree Collapse file tree 6 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 45
45
import com .adobe .cq .commerce .core .components .utils .SiteNavigation ;
46
46
import com .adobe .cq .commerce .magento .graphql .ConfigurableProduct ;
47
47
import com .adobe .cq .commerce .magento .graphql .ConfigurableVariant ;
48
+ import com .adobe .cq .commerce .magento .graphql .ProductImage ;
48
49
import com .adobe .cq .commerce .magento .graphql .ProductInterface ;
49
50
import com .adobe .cq .commerce .magento .graphql .SimpleProduct ;
50
51
import com .day .cq .wcm .api .Page ;
@@ -144,12 +145,13 @@ public List<ProductListItem> getProducts() {
144
145
145
146
try {
146
147
Price price = new PriceImpl (product .getPriceRange (), locale );
148
+ ProductImage thumbnail = product .getThumbnail ();
147
149
carouselProductList .add (new ProductListItemImpl (
148
150
skus .getLeft (),
149
151
slug ,
150
152
product .getName (),
151
153
price ,
152
- product . getThumbnail () .getUrl (),
154
+ thumbnail == null ? null : thumbnail .getUrl (),
153
155
productPage ,
154
156
skus .getRight (),
155
157
request ));
Original file line number Diff line number Diff line change 44
44
import com .adobe .cq .commerce .core .components .models .retriever .AbstractCategoryRetriever ;
45
45
import com .adobe .cq .commerce .core .components .utils .SiteNavigation ;
46
46
import com .adobe .cq .commerce .magento .graphql .CategoryProducts ;
47
+ import com .adobe .cq .commerce .magento .graphql .ProductImage ;
47
48
import com .adobe .cq .commerce .magento .graphql .ProductInterface ;
48
49
import com .adobe .cq .sightly .SightlyWCMMode ;
49
50
import com .day .cq .wcm .api .Page ;
@@ -216,12 +217,13 @@ public Collection<ProductListItem> getProducts() {
216
217
for (ProductInterface product : products .getItems ()) {
217
218
try {
218
219
Price price = new PriceImpl (product .getPriceRange (), locale );
220
+ ProductImage smallImage = product .getSmallImage ();
219
221
listItems .add (new ProductListItemImpl (
220
222
product .getSku (),
221
223
product .getUrlKey (),
222
224
product .getName (),
223
225
price ,
224
- product . getSmallImage () .getUrl (),
226
+ smallImage == null ? null : smallImage .getUrl (),
225
227
productPage ,
226
228
null ,
227
229
request ));
Original file line number Diff line number Diff line change 39
39
import com .adobe .cq .commerce .magento .graphql .ConfigurableProduct ;
40
40
import com .adobe .cq .commerce .magento .graphql .ConfigurableVariant ;
41
41
import com .adobe .cq .commerce .magento .graphql .Money ;
42
+ import com .adobe .cq .commerce .magento .graphql .ProductImage ;
42
43
import com .adobe .cq .commerce .magento .graphql .ProductInterface ;
43
44
import com .adobe .cq .commerce .magento .graphql .Query ;
44
45
import com .day .cq .wcm .api .Page ;
@@ -134,7 +135,13 @@ public void getProducts() {
134
135
priceFormatter .setCurrency (Currency .getInstance (amount .getCurrency ().toString ()));
135
136
Assert .assertEquals (priceFormatter .format (amount .getValue ()), item .getFormattedPrice ());
136
137
137
- Assert .assertEquals (productOrVariant .getThumbnail ().getUrl (), item .getImageURL ());
138
+ ProductImage thumbnail = productOrVariant .getThumbnail ();
139
+ if (thumbnail == null ) {
140
+ // if thumbnail is missing for a product in GraphQL response then thumbnail is null for the related item
141
+ Assert .assertNull (item .getImageURL ());
142
+ } else {
143
+ Assert .assertEquals (thumbnail .getUrl (), item .getImageURL ());
144
+ }
138
145
idx ++;
139
146
}
140
147
}
Original file line number Diff line number Diff line change 40
40
import com .adobe .cq .commerce .graphql .client .GraphqlClient ;
41
41
import com .adobe .cq .commerce .magento .graphql .CategoryInterface ;
42
42
import com .adobe .cq .commerce .magento .graphql .CategoryTree ;
43
+ import com .adobe .cq .commerce .magento .graphql .ProductImage ;
43
44
import com .adobe .cq .commerce .magento .graphql .ProductInterface ;
44
45
import com .adobe .cq .commerce .magento .graphql .Query ;
45
46
import com .adobe .cq .commerce .magento .graphql .StoreConfig ;
@@ -170,7 +171,13 @@ public void getProducts() {
170
171
Assert .assertEquals (priceFormatter .format (productInterface .getPriceRange ().getMinimumPrice ().getFinalPrice ().getValue ()), item
171
172
.getFormattedPrice ());
172
173
173
- Assert .assertEquals (productInterface .getSmallImage ().getUrl (), item .getImageURL ());
174
+ ProductImage smallImage = productInterface .getSmallImage ();
175
+ if (smallImage == null ) {
176
+ // if small image is missing for a product in GraphQL response then image URL is null for the related item
177
+ Assert .assertNull (item .getImageURL ());
178
+ } else {
179
+ Assert .assertEquals (smallImage .getUrl (), item .getImageURL ());
180
+ }
174
181
}
175
182
}
176
183
Original file line number Diff line number Diff line change 130
130
"id" : 1099 ,
131
131
"sku" : " eqrusugor" ,
132
132
"name" : " GoMobile Fitness Monitor/Smart Music Player" ,
133
- "small_image" : {
134
- "url" : " https://some-hostname.magentosite.cloud/media/catalog/product/g/o/gomobile_wrist_2.jpg"
135
- },
136
133
"url_key" : " gomobile-fitness-monitor-smart-music-player" ,
137
134
"price_range" : {
138
135
"minimum_price" : {
Original file line number Diff line number Diff line change 442
442
"__typename" : " ConfigurableProduct" ,
443
443
"sku" : " WJ01" ,
444
444
"name" : " Stellar Solar Jacket" ,
445
- "thumbnail" : {
446
- "label" : " Stellar Solar Jacket" ,
447
- "url" : " https://test-url.magentosite.cloud/media/wj01-red_main_6.jpg"
448
- },
449
445
"url_key" : " stellar-solar-jacket" ,
450
446
"price_range" : {
451
447
"minimum_price" : {
You can’t perform that action at this time.
0 commit comments