productos...
This commit is contained in:
parent
7aa6e7f767
commit
8d4ebb36e1
|
|
@ -31,10 +31,13 @@ public record IntegrationProperties(
|
||||||
* @param baseUrl full API base URL, e.g. {@code https://host/tienda/api}
|
* @param baseUrl full API base URL, e.g. {@code https://host/tienda/api}
|
||||||
* @param apiKey webservice key sent as {@code ws_key} query param
|
* @param apiKey webservice key sent as {@code ws_key} query param
|
||||||
* @param defaultCategoryId PrestaShop category ID assigned to new products (default: 2 = Home)
|
* @param defaultCategoryId PrestaShop category ID assigned to new products (default: 2 = Home)
|
||||||
|
* @param languageId PrestaShop language ID used for all multilingual fields (name, description, etc.)
|
||||||
|
* Check yours at GET /api/languages. Default 1 is usually English; set to Spanish ID.
|
||||||
*/
|
*/
|
||||||
public record Prestashop(
|
public record Prestashop(
|
||||||
@NotBlank String baseUrl,
|
@NotBlank String baseUrl,
|
||||||
@NotBlank String apiKey,
|
@NotBlank String apiKey,
|
||||||
int defaultCategoryId
|
int defaultCategoryId,
|
||||||
|
int languageId
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ public class PrestashopClient {
|
||||||
|
|
||||||
private final RestClient restClient;
|
private final RestClient restClient;
|
||||||
private final String wsKey;
|
private final String wsKey;
|
||||||
|
private final String languageId;
|
||||||
|
|
||||||
public PrestashopClient(
|
public PrestashopClient(
|
||||||
@Qualifier("prestashopRestClient") RestClient restClient,
|
@Qualifier("prestashopRestClient") RestClient restClient,
|
||||||
|
|
@ -39,6 +40,7 @@ public class PrestashopClient {
|
||||||
) {
|
) {
|
||||||
this.restClient = restClient;
|
this.restClient = restClient;
|
||||||
this.wsKey = props.prestashop().apiKey();
|
this.wsKey = props.prestashop().apiKey();
|
||||||
|
this.languageId = String.valueOf(props.prestashop().languageId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Products ──────────────────────────────────────────────────────────
|
// ── Products ──────────────────────────────────────────────────────────
|
||||||
|
|
@ -312,10 +314,10 @@ public class PrestashopClient {
|
||||||
sb.append("<available_for_order>1</available_for_order>");
|
sb.append("<available_for_order>1</available_for_order>");
|
||||||
sb.append("<show_price>1</show_price>");
|
sb.append("<show_price>1</show_price>");
|
||||||
sb.append("<visibility>both</visibility>");
|
sb.append("<visibility>both</visibility>");
|
||||||
sb.append("<link_rewrite><language id=\"1\">").append(escapeXml(slug)).append("</language></link_rewrite>");
|
sb.append("<link_rewrite><language id=\"").append(languageId).append("\">").append(escapeXml(slug)).append("</language></link_rewrite>");
|
||||||
sb.append("<name><language id=\"1\">").append(escapeXml(name)).append("</language></name>");
|
sb.append("<name><language id=\"").append(languageId).append("\">").append(escapeXml(name)).append("</language></name>");
|
||||||
sb.append("<description><language id=\"1\">").append(escapeXml(description)).append("</language></description>");
|
sb.append("<description><language id=\"").append(languageId).append("\">").append(escapeXml(description)).append("</language></description>");
|
||||||
sb.append("<description_short><language id=\"1\">").append(escapeXml(descShort)).append("</language></description_short>");
|
sb.append("<description_short><language id=\"").append(languageId).append("\">").append(escapeXml(descShort)).append("</language></description_short>");
|
||||||
List<String> cats = (dto.categoryIds() != null && !dto.categoryIds().isEmpty())
|
List<String> cats = (dto.categoryIds() != null && !dto.categoryIds().isEmpty())
|
||||||
? dto.categoryIds()
|
? dto.categoryIds()
|
||||||
: (dto.idCategoryDefault() != null ? List.of(dto.idCategoryDefault()) : List.of());
|
: (dto.idCategoryDefault() != null ? List.of(dto.idCategoryDefault()) : List.of());
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ integration:
|
||||||
base-url: ${PRESTASHOP_BASE_URL:https://prestashop.loading.net/tienda/api}
|
base-url: ${PRESTASHOP_BASE_URL:https://prestashop.loading.net/tienda/api}
|
||||||
api-key: ${PRESTASHOP_API_KEY}
|
api-key: ${PRESTASHOP_API_KEY}
|
||||||
default-category-id: 2
|
default-category-id: 2
|
||||||
|
language-id: ${PRESTASHOP_LANGUAGE_ID:1} # set to your Spanish language ID (check GET /api/languages)
|
||||||
|
|
||||||
api:
|
api:
|
||||||
security:
|
security:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue