Example #1
0
 public static function getThemeByProduct(Product $product)
 {
     $c = eq(__CLASS__ . '.productID', $product->getID());
     $c->addOr(self::getCategoryCondition($product->getCategory()));
     $f = select($c);
     $f->setOrder(new ARExpressionHandle('CategoryPresentation.productID=' . $product->getID()), 'DESC');
     self::setCategoryOrder($product->getCategory(), $f);
     // check if a theme is defined for this product particularly
     $set = ActiveRecordModel::getRecordSet(__CLASS__, $f, array('Category'));
     return self::getInheritedConfig($set);
 }
Example #2
0
 private function getRatingTypeFilter(Product $product)
 {
     $path = $product->getCategory()->getPathNodeArray(Category::INCLUDE_ROOT_NODE);
     $filter = new ARSelectFilter();
     $filter->setOrder(new ARFieldHandle("Category", "lft"), 'ASC');
     $filter->setOrder(new ARFieldHandle(__CLASS__, "position"), 'ASC');
     $cond = new EqualsCond(new ARFieldHandle(__CLASS__, "categoryID"), $product->getCategory()->getID());
     foreach ($path as $node) {
         $cond->addOR(new EqualsCond(new ARFieldHandle(__CLASS__, "categoryID"), $node['ID']));
     }
     $filter->setCondition($cond);
     return $filter;
 }
 public function editProduct(Product $product)
 {
     $editStmt = $this->db->prepare("UPDATE\n                            products\n                       SET\n                            name = ?, model = ?, price = ?, quantity = ?, category_id = ?\n                        WHERE id = ?")->execute([$product->getProductname(), $product->getProductmodel(), $product->getProductprice(), $product->getProductquantity(), $product->getCategory(), $product->getId()]);
     if ($editStmt->getAffectedRows() > 0) {
         return true;
     }
     return false;
 }
Example #4
0
 /**
  * Hozzá adja, elmenti az adatbázisban az új termék adatait.
  *
  * @param Product $product
  * @return Exception|string
  */
 public function productAddStore($product)
 {
     //die("temrék neve: " . $product->getName());
     if ($this->checkProductExist($product->getName()) === FALSE) {
         try {
             self::$conn->preparedInsert("termekek", array("nev", "kat_azon", "kisz_azon", "suly", "egysegar", "min_keszlet", "min_rend", "kim_azon", "akcio", "reszletek", "kep"), array($product->getName(), $product->getCategory(), $product->getPackage(), $product->getWeight(), $product->getPrice(), $product->getMinStock(), $product->getMinOrder(), $product->getHighlight(), $product->getDiscount(), $product->getDescription(), $product->getImg()));
             //die("Sql után!");
         } catch (Exception $e) {
             return new Exception("Nem sikerült elmenteni a terméket!");
         }
         //$stmt = $conn->preparedQuery("SELECT t_azon FROM termekek WHERE nev=?",array("$name"));
         return "Sikeres termék felvitel!";
     } else {
         return "Létezik már ilyen termék!";
     }
 }
 //Create Product Sheet
 $ws_name = $product_counter . ' - ' . $p->code;
 $obj_ws = $obj_excel->createSheet($product_counter);
 $obj_ws->setTitle($ws_name);
 $obj_ws->getColumnDimension('A')->setWidth($el_colwidth);
 $obj_ws->getColumnDimension('B')->setWidth($el_colwidth);
 $obj_ws->getColumnDimension('C')->setWidth($el_colwidth * 3);
 $obj_ws->getColumnDimension('D')->setWidth($el_colwidth);
 $obj_ws->getColumnDimension('E')->setWidth($el_colwidth);
 $obj_ws->getColumnDimension('F')->setWidth($el_colwidth);
 $obj_ws->getColumnDimension('G')->setWidth($el_colwidth * 2);
 $obj_ws->getColumnDimension('H')->setWidth($el_colwidth * 2);
 $obj_ws->getColumnDimension('I')->setWidth($el_colwidth * 2);
 $obj_ws->getStyle('A1:A2')->getFont()->setSize(14)->setBold(true);
 $obj_ws->setCellValue('A1', 'Product Code: ' . $p->code);
 $obj_ws->setCellValue('A2', $p->getCategory()->getName(LANGUAGEID) . ' ' . $p->getNameRaw(LANGUAGEID));
 //Product Images
 $row_products_images = '4';
 $p_image = DIR_WS_IMAGES . $p->image;
 if (is_file($p_image)) {
     $img_path = thumbimage($p_image, $pi2_width, $pi2_height, 1, 1, DIR_WS_IMAGES . 'imagecache');
     $obj_excel_draw = new PHPExcel_Worksheet_Drawing();
     $obj_excel_draw->setWorksheet($obj_ws);
     $obj_excel_draw->setPath($img_path);
     $obj_excel_draw->setCoordinates('A' . $row_products_images);
     $obj_excel_draw->setOffsetX($img_offset);
     $obj_excel_draw->setOffsetY($img_offset);
     $obj_ws->getRowDimension($row_products_images)->setRowHeight($pi2_rowheight);
 }
 $total_additional_image = $p->getAdditionalImageTotal();
 if ($total_additional_image > 0) {
 $content .= '<div>' . '<span id="cogs-manual-form" style="display:none;">' . '<input type="text" id="cogs-manual-input" value="' . $cogs . '" class="w100 tac" />' . '<br /><span class="notice">Set to 0 to use auto calculation</span>' . '</span>' . '<input type="button" id="cogs-manual-set" value="Set COGS Manually" />' . '</div>';
 $content .= '</div>';
 $content .= '</div>';
 //#left-panel
 //MAIN FORM
 $style_margin_left = 'margin-left:' . (IMAGE_SIZE_THUMBNAIL_3 + 60) . 'px;';
 $content .= '<div id="main-form" style="width:600px;' . $style_margin_left . '">';
 $content .= '<form name="update_product" action="?open=product-detail&amp;products_id=' . $products_id . '" method="post">';
 $content .= '<input type="hidden" name="me_action" value="UPDATEPRODUCTINFO" />';
 $content .= '<input type="hidden" name="products_id" value="' . $products_id . '" />';
 $content .= '<div><table class="main w900" border="0" cellspacing="0" cellpadding="2">';
 $content .= '<tr><td colspan="2"><h2 style="margin:0;">' . $obj_product->getName('2') . '</h2></td></tr>';
 $content .= '<tr><td colspan="2"><hr /></td></tr>';
 $content .= '<tr>';
 $content .= '<td class="w200">TOP Category</td>';
 $content .= '<td>' . $obj_product->getCategory()->getCategoryTop()->name . '</td>';
 $content .= '</tr><tr>';
 $content .= '<td>Category</td>';
 $content .= '<td>' . $obj_product->getCategory()->getName('1') . ' / ' . $obj_product->getCategory()->getName('2') . '</td>';
 $content .= '</tr><tr>';
 $content .= '<td>Product ID / Code</td>';
 $content .= '<td>' . $obj_product->id . ' / ' . $obj_product->code . '</td>';
 $content .= '</tr><tr>';
 //$content .= '<td>Product Code</td>';
 //$content .= '<td><input type="text" name="products_model" value="'.$products['products_model'].'" class="input" '.$code_changable.' /></td>';
 //$content .= '</tr><tr>';
 $content .= '<td>Date Finalized</td>';
 //$content .= '<td>Date Finalized<br /><span class="smallText notice">* previously "Date Added"</span></td>';
 $content .= '<td>' . date('d.m.Y H:i:s', strtotime($products['products_date_added']));
 //$content .= '<td><input type=text" value="'.date('d.m.Y H:i:s', strtotime($products['products_date_added'])).'" class="input" readonly="readonly" />';
 //$content .= ' <input type="text" class="date_picker" name="products_date_added" value="'.$date_added.'" readonly="readonly" />';
/**
 * Get cell value for Lazada and Zalora catalog cell
 * @global Int $jng_sp_id
 * @global Array $sp_detail
 * @param String $column_key
 * @param Product $product
 * @param Int $aid
 * @return String
 */
function getLazadaZaloraCatalogCellValue($column_key, $product, $aid)
{
    global $class_pa, $class_pb, $jng_sp_id, $sp_detail, $sp_values_brand, $sp_values_colors, $sp_values_navcat, $sp_values_navsubcat, $category_top_id;
    $lid = $sp_detail['languages_id'];
    if (!isset($sp_values_brand[$product->brand_id])) {
        $sp_brands = $class_pb->getSPbrands($product->brand_id);
        $sp_values_brand[$product->brand_id] = $sp_brands[$jng_sp_id];
    }
    $product_old_function = $product->getOldProductFunction()->retrieveDetail($product->id, 'p,pd,pd2,pc,pnc,cat,pei,pci');
    $category_id = $product->category_id;
    switch ($column_key) {
        //MIXED COLUMNS FROM LAZADA AND ZALORA TEMPLATE
        //FROM LAZADA TEMPLATE (some is also used by Zalora)
        case 'Name':
            //TODO: Create new function getNameBySalesPartner
            //      using SalesPartner object, no more need for sp id check
            if ($jng_sp_id == '1001') {
                //LAZADA NAME
                if ($category_top_id == '1') {
                    //JEWELRY
                    $value = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product_old_function['pd'][3]['products_name'] . ' ' . $product->getColors($lid);
                } else {
                    $value = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product->getName($lid) . ' ' . $product->getColors($lid);
                }
            } else {
                if ($category_top_id == '1') {
                    $value = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product_old_function['pd'][3]['products_name'] . ' ' . $product->getColors($lid);
                } else {
                    $value = $product->getName($lid);
                }
            }
            break;
        case 'PrimaryCategory':
            if ($jng_sp_id == '1002') {
                //27.04.2015 >> zalora made changed that primary category must same with sub category
                $param_key = $product->getSubCategory() . '-' . $product->getProductGenderID();
                $value = $sp_values_navsubcat[$param_key];
            } else {
                $param_key = $product->getCategory()->id . '-' . $product->getProductGenderID();
                $value = $sp_values_navcat[$param_key];
            }
            break;
        case 'Brand':
            $value = $sp_values_brand[$product->brand_id];
            break;
        case 'Categories':
            $param_key = $product->getSubCategory() . '-' . $product->getProductGenderID();
            $value = $sp_values_navsubcat[$param_key];
            break;
        case 'Model':
            $value = '';
            break;
        case 'Color':
            $value = $product->getColors($lid);
            break;
        case 'SalePrice':
            $price = $product->getPriceSelling($jng_sp_id);
            $price_old = $product->getPriceSellingOld($jng_sp_id);
            if ($price_old <= $price) {
                //show blank if its not discounted
                $price = '';
            }
            $value = $price;
            break;
        case 'Price':
            $price = $product->getPriceSelling($jng_sp_id);
            $price_old = $product->getPriceSellingOld($jng_sp_id);
            if ($price_old <= $price) {
                $price_old = $price;
            }
            $value = $price_old;
            break;
        case 'SaleStartDate':
            $price = $product->getPriceSelling($jng_sp_id);
            $price_old = $product->getPriceSellingOld($jng_sp_id);
            if ($price_old <= $price) {
                $sale_start_date = '';
            } else {
                $sale_start_date = date('Y-m-d');
            }
            $value = $sale_start_date;
            break;
        case 'SaleEndDate':
            $price = $product->getPriceSelling($jng_sp_id);
            $price_old = $product->getPriceSellingOld($jng_sp_id);
            if ($price_old <= $price) {
                $sale_end_date = '';
            } else {
                $sale_end_date = LAZADA_ZALORA_DEFAULT_SALE_END_DATE;
            }
            $value = $sale_end_date;
            break;
        case 'SellerSku':
            $value = $product->getSKU($aid);
            break;
        case 'Variation':
            //todo: translate ring sizes
            if ($category_top_id == '1') {
                if ($category_id == '29') {
                    $value = $product->convertRingSizeToJapaneseSize($product->getLengthOrSizeAsText($aid));
                } else {
                    $value = $jng_sp_id == '1001' ? 'One size' : 'One Size';
                }
            } else {
                $value = $product->getLengthOrSizeAsText($aid);
            }
            break;
        case 'ProductId':
            $value = $product->getEAN($aid);
            break;
        case 'ParentSku':
            $value = $product->getSKU('0');
            break;
        case 'Quantity':
            $value = $product->retrieveStockQuantity($aid);
            break;
            /*
                    case 'ProductLine':
               $value = $product->getKeywords($lid);
               break;
            */
        /*
                case 'ProductLine':
           $value = $product->getKeywords($lid);
           break;
        */
        case 'ColorFamily':
            $color_sp = '';
            $color_ids = $product->getColorIDAsArray();
            foreach ($color_ids as $cid) {
                if (isset($sp_values_colors[$cid])) {
                    $color_sp = $sp_values_colors[$cid];
                    break;
                }
            }
            $value = $color_sp;
            break;
            /*
                    case 'MaterialFamily':
               $value = '';
               break;
                    case 'MainMaterial':
               $value = '';
               break;
            */
        /*
                case 'MaterialFamily':
           $value = '';
           break;
                case 'MainMaterial':
           $value = '';
           break;
        */
        case 'Description':
            $value = $product->getDescription($lid);
            break;
        case 'Video':
            $value = '';
            break;
        case 'ShortDescription':
            $value = $product->getSellingPointsAsHTML($lid);
            break;
        case 'PackageContent':
            if ($jng_sp_id == '1001') {
                //LAZADA NAME
                if ($category_top_id == '1') {
                    //JEWELRY
                    $product_name = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product_old_function['pd'][3]['products_name'] . ' ' . $product->getColors($lid);
                } else {
                    $product_name = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product->getName($lid) . ' ' . $product->getColors($lid);
                }
            } else {
                if ($category_top_id == '1') {
                    $product_name = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product_old_function['pd'][3]['products_name'] . ' ' . $product->getColors($lid);
                } else {
                    $product_name = $product->getName($lid);
                }
            }
            $pc_list = array();
            $pc_list[] = $product_name;
            $pc_more_separator = '|||';
            $pc_list_more = ProductAttribute::displayAttributeName($product->id, ProductAttribute::GROUP_ID_PACKAGE_CONTENT, $lid, $pc_more_separator);
            if ($pc_list_more != '') {
                $pc_list_more_array = explode($pc_more_separator, $pc_list_more);
                foreach ($pc_list_more_array as $pc) {
                    $pc_list[] = $pc;
                }
            }
            $value = '<ul><li>' . implode('</li><li>', $pc_list) . '</li></ul>';
            break;
            /*    
                    case 'Note':
               $value = '';
               break;
            */
        /*    
                case 'Note':
           $value = '';
           break;
        */
        case 'MinDeliveryTime':
            $value = '2';
            break;
        case 'MaxDeliveryTime':
            $value = '5';
            break;
        case 'ProductMeasures':
            //ProductMeasures is from Lazada Template
        //ProductMeasures is from Lazada Template
        case 'Measurements':
            //Measurements is from Zalora Template
            if ($jng_sp_id == '1002') {
                $value = $product->displayMeasurement(1, $aid, '', $category_top_id == 1 || $category_top_id == 3 ? Product::FORMAT_DISPLAYMEASUREMENT_PM1 : Product::FORMAT_DISPLAYMEASUREMENT_AM2);
            } else {
                $value = $product->displayMeasurement($lid);
            }
            break;
        case 'ProductWeight':
            $value = $product->displayWeight($lid);
            break;
        case 'PackageHeight':
            //todo: use dynamic data
            $value = 3;
            break;
        case 'PackageWidth':
            //todo: use dynamic data
            $value = 35;
            break;
        case 'PackageLength':
            //todo: use dynamic data
            $value = 40;
            break;
        case 'PackageWeight':
            //todo: use dynamic data
            // 0.1 kg package * 300 gr default product weight
            $value = 0.4;
            break;
        case 'Certifications':
            $value = '';
            break;
        case 'ProductionCountry':
            $value = ProductAttribute::displayAttributeName($product->id, ProductAttribute::GROUP_ID_ORIGIN, $lid);
            break;
        case 'ManufacturerTxt':
            $value = '';
            break;
        case 'CareLabel':
            $value = ucfirst(strtolower(ProductAttribute::displayAttributeName($product->id, ProductAttribute::GROUP_ID_CARELABEL, $lid)));
            break;
        case 'ProductWarranty':
            $value = '';
            break;
        case 'MainImage':
            if ($jng_sp_id == '1001') {
                //send to lazada for all category products with image ratio 2 x 3
                $value = $product->getMainImageURL(1110, 1665);
            } else {
                $value = $product->getMainImageURL();
            }
            break;
        case 'Image2':
            $value = $product->getAdditionalImageURL(0, '');
            break;
        case 'Image3':
            $value = $product->getAdditionalImageURL(1, '');
            break;
        case 'Image4':
            $value = $product->getAdditionalImageURL(2, '');
            break;
        case 'Image5':
            $value = $product->getAdditionalImageURL(3, '');
            break;
        case 'Image6':
            $value = $product->getAdditionalImageURL(4, '');
            break;
        case 'Image7':
            $value = $product->getAdditionalImageURL(5, '');
            break;
        case 'Image8':
            $value = $product->getAdditionalImageURL(6, '');
            break;
        case 'Gender':
            $value = ucfirst($product->getProductGender('1'));
            break;
        case 'Season':
            $value = 'Year Round';
            break;
        case 'CompositionMaterial':
            $value = ucfirst(strtolower(ProductAttribute::displayAttributeName($product->id, ProductAttribute::GROUP_ID_COMPOSITION, $lid, ' ')));
            break;
        case 'Year':
            $value = date('Y');
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'Sizesystembrand':
            $value = '';
            //Zalora category Shoes
            if ($jng_sp_id == '1002' && $category_top_id == '4') {
                $value = 'EU';
            }
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'UpperMaterial':
            $value = '';
            //Zalora category Shoes
            if ($jng_sp_id == '1002' && $category_top_id == '4') {
                $value = 'Synthetic Leather';
            }
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'SoleMaterial':
            $value = '';
            //Zalora category Shoes
            if ($jng_sp_id == '1002' && $category_top_id == '4') {
                $value = 'PU';
            }
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'BuyerName':
            $value = '';
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'ModelsName':
            $value = '';
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'VirtusizeType':
            $value = '';
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'ShowChart':
            $value = '';
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'ShowVirtusize':
            $value = '';
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'SubCatType':
            $value = '';
            break;
            //FROM ZALORA TEMPLATE (not exist in Lazada)
        //FROM ZALORA TEMPLATE (not exist in Lazada)
        case 'WrapEligibility':
            $value = '';
            break;
        case 'SizeOrigin':
            $value = '';
            break;
        case 'Movement':
            $value = '';
            break;
        case 'Strap':
            $value = '';
            break;
        case 'MovementCountry':
            $value = '';
            break;
        case 'Condition':
            $value = 'Baru';
            break;
        default:
            $value = '';
    }
    return $value;
}