2016-09-30 3 views

답변

-1

이름 priceCalculation()

이 기능은 계산하고 다음 코드를 사용하여 제품 가격에 세금을 추가로 기능이 Product.php 클래스 파일을 편집하십시오 :

if ($use_tax) { 
     $price = $product_tax_calculator->addTaxes($price); 
    } 

$price += $ecotax_tax_calculator->addTaxes($ecotax); 

당신은 약간의 컨디셔닝을 추가 할 수 있습니다 제조업체가 원하는 결과를 얻을 수 있습니다.

0

제품을 내보낼 수있는 방법이나 내보내는 위치에서 문제를 조금 더 설명해 주실 수 있습니까? 그래서, 나는이 문제에 대한 정확한 해결책을 줄 수있다.

당신이 일반적인 솔루션을 원하는 경우, 아래의 코드로 찾아보세요 :

제품 클래스 파일을 엽니 다 ROOT_DIRECTORY/클래스/Product.php

편집 다음과 같은 기능 :

public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) { 

    parent::__construct($id_product, $id_lang, $id_shop); 

    if (empty($this->ean13)) { 
     $this->ean13 = $this->generateEAN13(); //New function 
    } 
    //Remaining part of this function keep same 
} 

EAN13을 생성하려면이 파일에 새 함수를 추가하십시오.

public function generateEAN13() { 
    $length = 13; 
    $ean_number = ''; 
    $chars = ''; 
    $maxlength = Tools::strlen($chars); 
    $i = 0; 
    while ($i < $length) { 
     $char = Tools::substr($chars, mt_rand(0, $maxlength - 1), 1); 
     if (!strstr($code, $char)) { 
      $code .= $char; 
      $i++; 
     } 
    } 

    //Check whether this ean alread exist or not for product 
    $sql = 'SELECT id_product FROM '._DB_PREFIX_.'product where ean13 = "'.pSQL($code).'"'; 
    if ((int)Db::getInstance()->getValue($sql) == 0) { 
     return $code; 
    } else { 
     //Check ean13 on combination 
     $sql = 'SELECT id_product_attribute FROM '._DB_PREFIX_.'product_attribute where ean13 = "'.pSQL($code).'"'; 
     if ((int)Db::getInstance()->getValue($sql) == 0) { 
      return $code; 
     } 
    } 

    return $this->generateEAN13(); 
} 

위의 코드는 제품 데이터를 얻을 때마다 ean13 번호가있는 제품을 제공하며 제품에는 EAN13이 없습니다.

+0

안녕하세요. 제 제품에 EAN 코드가 없습니다. 내 제품을 eBay로 내보내고 싶습니다 ...하지만 이베이는 모든 제품에 EAN 코드가 필요합니다. – Leon

+0

신제품 및 기존 제품에 대한 ean 코드를 생성해야합니다. – Leon

+0

안녕하세요,이 코드 만 카테고리로 시도해 볼 수 있습니까? – Leon