2014-11-05 2 views
1

: 나는 라이브 서버에 로컬 호스트에서 웹 서비스 API를 통해 제품을 추가 할 수 있지만 나는PrestaShop 버전 1.6 :하지만, 로컬 호스트에서 웹 서비스 API를 통해 제품을 추가 할 수 없습니다 라이브 서버에서 PrestaShop 버전 1.6에서

나는이 무엇입니까 오류 "Uncaught exception 'PrestaShopWebserviceException'with message 'PrestaShop 웹 서비스에 대한이 호출에 실패하여 HTTP 상태 500을 반환했습니다. 즉, 내부 서버 오류입니다.' 에서 "라이브 사이트에 대한 리눅스 서버에서 아래의 스크립트를 실행하는 동안,하지만 똑같은 작품 괜찮아요 localhost, 무슨 문제가 될 수 있을까? 네 물론 라이브 사이트의 PS_SHOP_PATH 및 PS_WS_AUTH_KEY 값을 변경했습니다.

<?php 
 
define('DEBUG', true); 
 
define('_PS_DEBUG_SQL_', true); 
 

 
define('PS_SHOP_PATH', 'http://localhost/prestashop'); 
 
define('PS_WS_AUTH_KEY', 'your-key-here'); 
 

 

 
    
 
require_once('PSWebServiceLibrary.php'); 
 
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); 
 
    
 

 
$xml_product = $webService->get(array('resource' => 'products?schema=blank')); 
 
$resources_product = $xml_product->children()->children(); 
 

 
    
 
$resources_product->id_manufacturer ='1'; 
 
$resources_product->id_supplier ='1'; 
 
$resources_product->id_category_default \t ='3'; 
 
//$resources_product->new \t ='1'; 
 
$resources_product->cache_default_attribute; 
 
$resources_product->id_default_image; 
 
$resources_product->id_default_combination; 
 
$resources_product->id_tax_rules_group; 
 
//$resources_product->position_in_category; \t 
 
$resources_product->manufacturer_name; \t 
 
//$resources_product->quantity="3"; \t 
 
$resources_product->type; 
 
$resources_product->id_shop_default; 
 
$resources_product->reference='SKUID45'; 
 
$resources_product->supplier_reference; 
 
$resources_product->location; 
 
$resources_product->width; 
 
$resources_product->height; \t 
 
$resources_product->depth; \t 
 
$resources_product->weight; 
 
$resources_product->quantity_discount; \t 
 
$resources_product->ean13; 
 
$resources_product->upc; 
 
$resources_product->cache_is_pack; 
 
$resources_product->cache_has_attachments; 
 
$resources_product->is_virtual; 
 
$resources_product->on_sale; 
 
$resources_product->online_only; 
 
$resources_product->ecotax; 
 
$resources_product->minimal_quantity; 
 
$resources_product->price='20.00'; 
 
$resources_product->wholesale_price; 
 
$resources_product->unity; 
 
$resources_product->unit_price_ratio; \t 
 
$resources_product->additional_shipping_cost; 
 
$resources_product->customizable; 
 
$resources_product->text_fields; 
 
$resources_product->uploadable_files; 
 
$resources_product->active='1'; 
 
$resources_product->redirect_type; 
 
$resources_product->id_product_redirected; 
 
$resources_product->available_for_order; 
 
$resources_product->available_date; \t 
 
$resources_product->condition ='new'; \t 
 
$resources_product->show_price; \t 
 
$resources_product->indexed \t ='1'; 
 
$resources_product->visibility = 'both'; 
 
$resources_product->advanced_stock_management; 
 
$resources_product->date_add; 
 
$resources_product->date_upd; 
 
$resources_product->meta_description->language ='Product Meta Description'; 
 
$resources_product->meta_keywords->language='Product Meta keywords'; 
 
$resources_product->meta_title->language='Product Meta Title'; 
 
$resources_product->link_rewrite->language='product-url-key'; \t 
 
$resources_product->name->language='Product Name'; \t 
 
$resources_product->description->language='Product Description'; 
 
$resources_product->description_short->language='Product Short Description '; 
 
$resources_product->available_now->language='30/10/14'; \t 
 
$resources_product->available_later->language; 
 
$resources_product->associations->categories->addChild('category')->addChild('id', 3); 
 

 

 
$xml_product = $webService->add(array('resource' => 'products', 'postXml' => $xml_product->asXML())); 
 
    
 
    ?>

답변

0

이 시도 :

define('PS_SHOP_PATH', 'http://localhost/prestashop/api/'); 

감사

+0

는 귀하의 회신, 주셔서 감사하지만 내가 첫 번째 줄에 말했듯이, "나는 통해 제품을 추가 할 수 있어요 localhost의 Webservices API (라이브 서버가 아님) " localhost의 모든 것이 정상적으로 작동합니다. , 추가, 편집, 이미지 업로드, 수량 편집. – alok

+0

라이브 서버에서 Webservices API를 활성화하고 ip live 서버의 localhost를 바꾸고 라이브 서버의 api 키에 대한 api 키를 변경하십시오. – esmoreno

+0

$ livesite = 0; // 로컬의 경우 0, 서버의 경우 1 if ($ livesite == 0) { ('PS_SHOP_PATH', 'http : // localhost/prestashop'); define ('PS_WS_AUTH_KEY', 'localhost-API-key-here'); } else { define ('PS_SHOP_PATH', 'http://www.example.com'); define ('PS_WS_AUTH_KEY', 'live-server-api-key-here'); 위의 코드를 사용하여 localhost와 라이브 서버간에 전환 할 수 있으므로 키와 경로에 대해서는 문제가되지 않으며 localhost와 live server에도 해당 API 키에 대한 모든 권한이 부여됩니다. – alok

관련 문제