first commit
This commit is contained in:
2
plugins/stMigrationSoteshopPlugin/config/config.php
Normal file
2
plugins/stMigrationSoteshopPlugin/config/config.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
stMigration::register('stMigrationSoteshopPlugin', array('soteshop40' => 'SOTEeSKLEP 4.0 (RC23 lub wyższa)', 'soteshop40RC1-RC22' => 'SOTEeSKLEP 4.0 (RC1 - RC22)', 'soteshop35' => 'SOTEeSKLEP 3.5', 'soteshop31' => 'SOTEeSKLEP 3.1', 'soteshop30' => 'SOTEeSKLEP 3.0'));
|
||||
@@ -0,0 +1,166 @@
|
||||
migration:
|
||||
_attributes:
|
||||
cleanup: [CategoryHasPositioningI18n, ProductHasPositioningI18n, Review, ProductSearchIndex, ProductOptionsValueI18n, ProductOptionsValue, ProductOptionsFieldI18n, ProductOptionsField, sfAsset, sfAssetFolder, ProductI18n, Product, CategoryI18n, Category, ProducerI18n, Producer, sfGuardUser, OrderCurrency, OrderUserDataBilling, OrderUserDataDelivery, OrderDelivery, Order]
|
||||
imports: [products, reviews, clients, orders]
|
||||
|
||||
products:
|
||||
params:
|
||||
source: {query: "SELECT * FROM main"}
|
||||
limit: 10
|
||||
description: Import produktów
|
||||
model_fillin:
|
||||
Product:
|
||||
created_at: {params: date_update}
|
||||
active: {params: active}
|
||||
wholesale_a_brutto: {params: price_brutto_2}
|
||||
price_brutto: {params: price_brutto}
|
||||
m_vat: {params: vat}
|
||||
m_name:
|
||||
params: {names: [name, en_name, de_name]}
|
||||
m_description:
|
||||
params: {descriptions: [xml_description, en_xml_description, de_xml_description]}
|
||||
m_short_description:
|
||||
params: {descriptions: [xml_short_description, en_xml_short_description, de_xml_short_description]}
|
||||
m_group: {params: [main_page, bestseller, promotion]}
|
||||
m_code: {params: user_id}
|
||||
m_category:
|
||||
params: {categories: [category1, category2, category3, category4, category5]}
|
||||
m_category_multi: {params: [category_multi_1, category_multi_2]}
|
||||
m_producer: {params: producer}
|
||||
m_product_options: {params: xml_options}
|
||||
m_image: {params: [photo, user_id]}
|
||||
reviews:
|
||||
params:
|
||||
source: {query: "SELECT * FROM reviews WHERE state = 1"}
|
||||
limit: 50
|
||||
description: Import recenzji
|
||||
model_fillin:
|
||||
Review:
|
||||
created_at: {params: date_add}
|
||||
m_product_id: {params: user_id}
|
||||
admin_name: {params: author}
|
||||
description: {params: description}
|
||||
score: {params: score}
|
||||
clients:
|
||||
params:
|
||||
source: {query: "SELECT * FROM users WHERE order_data = 0"}
|
||||
limit: 100
|
||||
description: Import klientów
|
||||
model_fillin:
|
||||
sfGuardUser:
|
||||
m_username: {params: crypt_login}
|
||||
m_password: {params: crypt_password}
|
||||
m_created_at: {params: [date_add, date_update]}
|
||||
m_wholesale: {params: hurt}
|
||||
m_user_data:
|
||||
params:
|
||||
billing:
|
||||
- crypt_firm
|
||||
- crypt_name
|
||||
- crypt_surname
|
||||
- crypt_street
|
||||
- crypt_street_n1
|
||||
- crypt_street_n2
|
||||
- crypt_country
|
||||
- crypt_postcode
|
||||
- crypt_nip
|
||||
- crypt_city
|
||||
- crypt_phone
|
||||
- crypt_email
|
||||
delivery:
|
||||
- crypt_cor_firm
|
||||
- crypt_cor_name
|
||||
- crypt_cor_surname
|
||||
- crypt_cor_street
|
||||
- crypt_cor_street_n1
|
||||
- crypt_cor_street_n2
|
||||
- crypt_cor_country
|
||||
- crypt_cor_postcode
|
||||
- crypt_cor_city
|
||||
- crypt_cor_phone
|
||||
- crypt_cor_email
|
||||
orders:
|
||||
params:
|
||||
source:
|
||||
count_query: "SELECT COUNT(*) FROM order_register"
|
||||
query: >
|
||||
SELECT o.order_id as o_id,
|
||||
o.confirm as o_confirm,
|
||||
o.confirm_user as o_confirm_user,
|
||||
o.delivery_cost as d_cost,
|
||||
o.date_add as o_date_add,
|
||||
o.time_add as o_time_add,
|
||||
o.date_update as o_date_update,
|
||||
o.confirm as o_confirm,
|
||||
o.confirm_online as o_confirm_online,
|
||||
o.id_pay_method as o_payment_id,
|
||||
d.name as d_name,
|
||||
u.crypt_login,
|
||||
u.date_add as u_date_add,
|
||||
u.date_update as u_date_update,
|
||||
ud.crypt_firm,
|
||||
ud.crypt_name,
|
||||
ud.crypt_surname,
|
||||
ud.crypt_street,
|
||||
ud.crypt_street_n1,
|
||||
ud.crypt_street_n2,
|
||||
ud.crypt_country,
|
||||
ud.crypt_postcode,
|
||||
ud.crypt_nip,
|
||||
ud.crypt_city,
|
||||
ud.crypt_phone,
|
||||
ud.crypt_email,
|
||||
ud.crypt_cor_firm,
|
||||
ud.crypt_cor_name,
|
||||
ud.crypt_cor_surname,
|
||||
ud.crypt_cor_street,
|
||||
ud.crypt_cor_street_n1,
|
||||
ud.crypt_cor_street_n2,
|
||||
ud.crypt_cor_country,
|
||||
ud.crypt_cor_postcode,
|
||||
ud.crypt_cor_city,
|
||||
ud.crypt_cor_phone,
|
||||
ud.crypt_cor_email
|
||||
FROM order_register o
|
||||
LEFT JOIN (delivery d) ON o.id_delivery = d.id
|
||||
LEFT JOIN (users u) ON o.id_users = u.id
|
||||
LEFT JOIN (users ud) ON o.id_users_data = ud.id
|
||||
limit: 100
|
||||
description: Import zamówień
|
||||
model_fillin:
|
||||
Order:
|
||||
m_created_at: {params: [o_date_add, o_time_add]}
|
||||
m_updated_at: {params: o_date_update}
|
||||
m_payment: {params: [o_payment_id, o_confirm, o_confirm_online]}
|
||||
m_id: {params: o_id}
|
||||
is_confirmed: {params: o_confirm_user}
|
||||
m_delivery: {params: [d_name, d_cost]}
|
||||
m_status: {params: o_confirm}
|
||||
m_user: {params: [crypt_login, crypt_email, u_date_add, u_date_update]}
|
||||
m_user_data:
|
||||
params:
|
||||
billing:
|
||||
- crypt_firm
|
||||
- crypt_name
|
||||
- crypt_surname
|
||||
- crypt_street
|
||||
- crypt_street_n1
|
||||
- crypt_street_n2
|
||||
- crypt_country
|
||||
- crypt_postcode
|
||||
- crypt_nip
|
||||
- crypt_city
|
||||
- crypt_phone
|
||||
- crypt_email
|
||||
delivery:
|
||||
- crypt_cor_firm
|
||||
- crypt_cor_name
|
||||
- crypt_cor_surname
|
||||
- crypt_cor_street
|
||||
- crypt_cor_street_n1
|
||||
- crypt_cor_street_n2
|
||||
- crypt_cor_country
|
||||
- crypt_cor_postcode
|
||||
- crypt_cor_city
|
||||
- crypt_cor_phone
|
||||
- crypt_cor_email
|
||||
@@ -0,0 +1,14 @@
|
||||
migration:
|
||||
_attributes:
|
||||
extend: soteshop30.yml
|
||||
|
||||
products:
|
||||
model_fillin:
|
||||
Product:
|
||||
weight: {params: weight}
|
||||
m_name:
|
||||
params: {names: [name_L0, name_L1, name_L2, name_L3, name_L4]}
|
||||
m_description:
|
||||
params: {descriptions: [xml_description_L0, xml_description_L1, xml_description_L2, xml_description_L3, xml_description_L4]}
|
||||
m_short_description:
|
||||
params: {descriptions: [xml_short_description_L0, xml_short_description_L1, xml_short_description_L2, xml_short_description_L3, xml_short_description_L4]}
|
||||
@@ -0,0 +1,11 @@
|
||||
migration:
|
||||
_attributes:
|
||||
extend: soteshop31.yml
|
||||
|
||||
products:
|
||||
params:
|
||||
source: {query: "SELECT m.*, d.num as stock FROM main m LEFT JOIN (depository d) ON d.user_id_main = m.user_id"}
|
||||
model_fillin:
|
||||
Product:
|
||||
stock: {params: stock}
|
||||
m_positioning: {params: [google_title, google_keywords, google_description]}
|
||||
@@ -0,0 +1,7 @@
|
||||
migration:
|
||||
_attributes:
|
||||
extend: soteshop40RC1-RC22.yml
|
||||
|
||||
products:
|
||||
params:
|
||||
source: {query: "SELECT m.*, d.num AS stock FROM main m LEFT JOIN (depository d) ON d.user_id_main = m.user_id AND (d.adv_attr = '*' OR d.adv_attr is NULL)"}
|
||||
@@ -0,0 +1,11 @@
|
||||
migration:
|
||||
_attributes:
|
||||
extend: soteshop35.yml
|
||||
|
||||
products:
|
||||
model_fillin:
|
||||
Product:
|
||||
m_category:
|
||||
params: {ids: [id_category1, id_category2, id_category3, id_category4, id_category5]}
|
||||
m_product_options: {params: [xml_options, user_id]}
|
||||
m_image: {params: [photo_uid, photo_count, photo, user_id]}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationOrder.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationOrder extends stMigrationSoteshopOrderBase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationProduct.class.php 13946 2011-07-05 13:22:43Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationProduct extends stMigrationModel
|
||||
{
|
||||
protected $rootCategory = null;
|
||||
|
||||
protected $mProductOptions = null;
|
||||
|
||||
protected $mWholesale = null;
|
||||
|
||||
public function postSave($product, $con = null)
|
||||
{
|
||||
|
||||
$default = true;
|
||||
|
||||
foreach ($product->mImageFiles as $image)
|
||||
{
|
||||
$this->addImageToProduct($product, $image, $default, $con);
|
||||
|
||||
$default = false;
|
||||
}
|
||||
|
||||
$this->addProductOptions($product, $this->mProductOptions, $con);
|
||||
}
|
||||
|
||||
public function setMCode($product, $v)
|
||||
{
|
||||
$v = stMigrationSoteshopHelper::fixString($v);
|
||||
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductPeer::CODE, $v);
|
||||
|
||||
$same_product = ProductPeer::doSelectOne($c);
|
||||
|
||||
$product->setCode(is_object($same_product) ? 'DUPLICATE_' . $v : $v);
|
||||
}
|
||||
|
||||
public function setMVat($product, $v)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(TaxPeer::VAT, $v);
|
||||
|
||||
$tax = TaxPeer::doSelectOne($c);
|
||||
|
||||
if (is_null($tax))
|
||||
{
|
||||
$tax = new Tax();
|
||||
|
||||
$tax->setVat($v);
|
||||
}
|
||||
|
||||
$product->setOptVat($v);
|
||||
|
||||
$product->setTax($tax);
|
||||
}
|
||||
|
||||
public function setMProducer($product, $v)
|
||||
{
|
||||
if (!empty($v))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProducerI18nPeer::NAME, $v);
|
||||
|
||||
$c->add(ProducerI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$producer = ProducerPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($producer[0]))
|
||||
{
|
||||
$producer = new Producer();
|
||||
|
||||
$producer->setCulture('pl_PL');
|
||||
|
||||
$producer->setName($v);
|
||||
}
|
||||
else
|
||||
{
|
||||
$producer = $producer[0];
|
||||
}
|
||||
|
||||
$product->setProducer($producer);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMName($product, $names)
|
||||
{
|
||||
if (!empty($names['name']))
|
||||
{
|
||||
$product->setCulture('pl_PL');
|
||||
|
||||
$product->setName($names['name']);
|
||||
}
|
||||
|
||||
if (!empty($names['en_name']))
|
||||
{
|
||||
$product->setCulture('en_US');
|
||||
|
||||
$product->setName($names['en_name']);
|
||||
}
|
||||
|
||||
if (!empty($names['de_name']))
|
||||
{
|
||||
$product->setCulture('de');
|
||||
|
||||
$product->setName($names['de_name']);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMDescription($product, $descriptions)
|
||||
{
|
||||
if (!empty($descriptions['xml_description']))
|
||||
{
|
||||
$product->setCulture('pl_PL');
|
||||
|
||||
$product->setDescription($descriptions['xml_description']);
|
||||
}
|
||||
|
||||
if (!empty($descriptions['en_xml_description']))
|
||||
{
|
||||
$product->setCulture('en_US');
|
||||
|
||||
$product->setDescription($descriptions['en_xml_description']);
|
||||
}
|
||||
|
||||
if (!empty($descriptions['de_xml_description']))
|
||||
{
|
||||
$product->setCulture('de');
|
||||
|
||||
$product->setDescription($descriptions['de_xml_description']);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMShortDescription($product, $descriptions)
|
||||
{
|
||||
if (!empty($descriptions['xml_description']))
|
||||
{
|
||||
$product->setCulture('pl_PL');
|
||||
|
||||
$product->setShortDescription($descriptions['xml_description']);
|
||||
}
|
||||
|
||||
if (!empty($descriptions['en_xml_short_description']))
|
||||
{
|
||||
$product->setCulture('en_US');
|
||||
|
||||
$product->setShortDescription($descriptions['en_xml_short_description']);
|
||||
}
|
||||
|
||||
if (!empty($descriptions['de_xml_short_description']))
|
||||
{
|
||||
$product->setCulture('de');
|
||||
|
||||
$product->setShortDescription($descriptions['de_xml_short_description']);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMImage($product, $v, $user_id)
|
||||
{
|
||||
$pathinfo = pathinfo($v);
|
||||
|
||||
$ext = isset($pathinfo['extension']) ? $pathinfo['extension'] : '';
|
||||
|
||||
$image = isset($pathinfo['filename']) ? $pathinfo['filename'] : '';
|
||||
|
||||
$product->mImageFiles = array();
|
||||
|
||||
$this->getLogger()->info(sprintf('Przenosze zdjęcia z produktu o id "%s" do produktu o kodzie "%s"', $user_id, $product->getCode()));
|
||||
|
||||
if (strtolower($ext) == 'jpg' || strtolower($ext) == 'gif' || strtolower($ext) == 'png')
|
||||
{
|
||||
for($i = 0; $i <= 10; $i++)
|
||||
{
|
||||
$filename = stMigrationSoteshopHelper::fixString($image) . ($i ? '-' . $i : '') . '.' . $ext;
|
||||
|
||||
$url_filename = rawurlencode($image) . ($i ? '-' . $i : '') . '.' . $ext;
|
||||
|
||||
$image_path = $this->uploadImage($this->getMigrationParam('www') . '/photo/' . $url_filename);
|
||||
|
||||
if ($image_path)
|
||||
{
|
||||
$product->mImageFiles[] = $image_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getLogger()->notice('Produkt nie zawiera zdjęć...');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMGroup($product, $main_page, $bestseller, $promotion)
|
||||
{
|
||||
if (!empty($main_page))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'MAIN_PAGE');
|
||||
}
|
||||
|
||||
if (!empty($promotion))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'PROMOTION');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMCategoryMulti($product, $category_multi_1, $category_multi_2)
|
||||
{
|
||||
if (!empty($category_multi_1))
|
||||
{
|
||||
$categories = explode("/", $category_multi_1);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
if (!empty($category_multi_2))
|
||||
{
|
||||
$categories = explode("/", $category_multi_2);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $product
|
||||
*/
|
||||
public function setMCategory($product, $categories)
|
||||
{
|
||||
$category = $this->categoryWalk(array_values($categories));
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
public function setMPrice($product, $price_brutto, $vat)
|
||||
{
|
||||
$product->setPriceNettoByBrutto($price_brutto, $vat);
|
||||
}
|
||||
|
||||
public function setMProductOptions($product, $xml_options)
|
||||
{
|
||||
$this->mProductOptions = $xml_options;
|
||||
}
|
||||
|
||||
protected function addProductOptions($product, $xml_options, $con = null)
|
||||
{
|
||||
if (!empty($xml_options))
|
||||
{
|
||||
$root = new ProductOptionsValue();
|
||||
|
||||
$root->makeRoot();
|
||||
|
||||
$root->setProduct($product);
|
||||
|
||||
$root->setCulture('pl_PL');
|
||||
|
||||
$root->save($con);
|
||||
|
||||
$attributes = stMigrationSoteshopHelper::xmlOptionsToArray($xml_options);
|
||||
|
||||
$this->addProductOptionsRecursive($product, $attributes, $root, $con);
|
||||
}
|
||||
}
|
||||
|
||||
protected function addProductOptionsRecursive($product, $attributes, $root, $con = null)
|
||||
{
|
||||
if (!is_array($attributes)) return;
|
||||
|
||||
foreach ($attributes as $name => $options)
|
||||
{
|
||||
$pof = new ProductOptionsField();
|
||||
|
||||
$pof->setCulture('pl_PL');
|
||||
|
||||
$pof->setName($name);
|
||||
|
||||
$pof->save($con);
|
||||
|
||||
foreach ($options as $name => $params)
|
||||
{
|
||||
// $root = $root->reload();
|
||||
|
||||
$pov = new ProductOptionsValue();
|
||||
|
||||
$pov->setCulture('pl_PL');
|
||||
|
||||
$pov->setProduct($product);
|
||||
|
||||
$pov->setProductOptionsField($pof);
|
||||
|
||||
$pov->setValue($name);
|
||||
|
||||
$pov->setPrice($params['price']);
|
||||
|
||||
$pov->insertAsLastChildOf($root);
|
||||
|
||||
$pov->save($con);
|
||||
|
||||
$root->setRgt($pov->getRgt()+1);
|
||||
|
||||
// $this->addProductOptionsRecursive($product, $params['nested'], $pov, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function categoryWalk($path)
|
||||
{
|
||||
$tmp = $this->getRootCategory();
|
||||
|
||||
if (is_null($tmp))
|
||||
{
|
||||
$tmp = new Category();
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
$tmp->setName('Kategorie');
|
||||
|
||||
$tmp->makeRoot();
|
||||
|
||||
$tmp->save();
|
||||
|
||||
$tmp->setScope($tmp->getId());
|
||||
|
||||
$tmp->save();
|
||||
}
|
||||
|
||||
$tmp = $tmp->reload();
|
||||
|
||||
$count = count($path);
|
||||
|
||||
for($i = 0; $i < $count && !empty($path[$i]); $i++)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryI18nPeer::NAME, $path[$i]);
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, $tmp->getId());
|
||||
|
||||
$c->add(CategoryI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$category = CategoryPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($category[0]))
|
||||
break;
|
||||
|
||||
$tmp = $category[0];
|
||||
}
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
for($j = $i; $j < $count && !empty($path[$j]); $j++)
|
||||
{
|
||||
|
||||
$category = new Category();
|
||||
|
||||
$category->setCulture('pl_PL');
|
||||
|
||||
$category->setName($path[$j]);
|
||||
|
||||
$category->insertAsLastChildOf($tmp);
|
||||
|
||||
$category->save();
|
||||
|
||||
$tmp = $category;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function getRootCategory()
|
||||
{
|
||||
if (is_null($this->rootCategory))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, null, Criteria::ISNULL);
|
||||
|
||||
$this->rootCategory = CategoryPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
return $this->rootCategory;
|
||||
}
|
||||
|
||||
protected function getProductGroupByType($type = 'MAIN_PAGE')
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductGroupPeer::PRODUCT_GROUP, $type);
|
||||
|
||||
return ProductGroupPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
protected function addProductToGroupType($product, $group_type = 'MAIN_PAGE')
|
||||
{
|
||||
$product_group = $this->getProductGroupByType($group_type);
|
||||
|
||||
$product_group_has_product = new ProductGroupHasProduct();
|
||||
|
||||
$product_group_has_product->setProduct($product);
|
||||
|
||||
$product_group_has_product->setProductGroup($product_group);
|
||||
|
||||
$product->addProductGroupHasProduct($product_group_has_product);
|
||||
}
|
||||
|
||||
protected function addProductToCategory($product, $category)
|
||||
{
|
||||
$product_has_category = new ProductHasCategory();
|
||||
|
||||
$product_has_category->setCategory($category);
|
||||
|
||||
$product->addProductHasCategory($product_has_category);
|
||||
}
|
||||
|
||||
protected function addImageToProduct($product, $image, $default = false, $con = null)
|
||||
{
|
||||
$product_has_asset = new ProductHasSfAsset();
|
||||
|
||||
$product_has_asset->setIsDefault($default);
|
||||
|
||||
$product_has_asset->setProduct($product);
|
||||
|
||||
$product_has_asset->createAsset(basename($image), $image, ProductHasSfAssetPeer::IMAGE_FOLDER);
|
||||
|
||||
$product_has_asset->save($con);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationReview.class.php 16984 2012-02-07 12:00:51Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationReview extends stMigrationSoteshopReviewBase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationsfGuardUser.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationsfGuardUser extends stMigrationSoteshopGuardUserModel
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationOrder.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationOrder extends stMigrationSoteshopOrderBase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationProduct.class.php 13946 2011-07-05 13:22:43Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationProduct extends stMigrationModel
|
||||
{
|
||||
protected $rootCategory = null;
|
||||
|
||||
protected $mProductOptions = null;
|
||||
|
||||
protected $mWholesale = null;
|
||||
|
||||
public function postSave($product, $con = null)
|
||||
{
|
||||
|
||||
$default = true;
|
||||
|
||||
foreach ($product->mImageFiles as $image)
|
||||
{
|
||||
$this->addImageToProduct($product, $image, $default, $con);
|
||||
|
||||
$default = false;
|
||||
}
|
||||
|
||||
$this->addProductOptions($product, $this->mProductOptions, $con);
|
||||
}
|
||||
|
||||
public function setMCode($product, $v)
|
||||
{
|
||||
$v = stMigrationSoteshopHelper::fixString($v);
|
||||
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductPeer::CODE, $v);
|
||||
|
||||
$same_product = ProductPeer::doSelectOne($c);
|
||||
|
||||
$product->setCode(is_object($same_product) ? 'DUPLICATE_' . $v : $v);
|
||||
}
|
||||
|
||||
public function setMVat($product, $v)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(TaxPeer::VAT, $v);
|
||||
|
||||
$tax = TaxPeer::doSelectOne($c);
|
||||
|
||||
if (is_null($tax))
|
||||
{
|
||||
$tax = new Tax();
|
||||
|
||||
$tax->setVat($v);
|
||||
}
|
||||
|
||||
$product->setOptVat($v);
|
||||
|
||||
$product->setTax($tax);
|
||||
}
|
||||
|
||||
public function setMProducer($product, $v)
|
||||
{
|
||||
if (!empty($v))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProducerI18nPeer::NAME, $v);
|
||||
|
||||
$c->add(ProducerI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$producer = ProducerPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($producer[0]))
|
||||
{
|
||||
$producer = new Producer();
|
||||
|
||||
$producer->setCulture('pl_PL');
|
||||
|
||||
$producer->setName($v);
|
||||
}
|
||||
else
|
||||
{
|
||||
$producer = $producer[0];
|
||||
}
|
||||
|
||||
$product->setProducer($producer);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMName($product, $names)
|
||||
{
|
||||
$names = array_values($names);
|
||||
|
||||
$count = count($names);
|
||||
|
||||
for($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($names[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setName($names[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMDescription($product, $descriptions)
|
||||
{
|
||||
$descriptions = array_values($descriptions);
|
||||
|
||||
$count = count($descriptions);
|
||||
|
||||
for($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($descriptions[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setDescription($descriptions[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMShortDescription($product, $descriptions)
|
||||
{
|
||||
$descriptions = array_values($descriptions);
|
||||
|
||||
$count = count($descriptions);
|
||||
|
||||
for($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($descriptions[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setShortDescription($descriptions[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMImage($product, $v, $user_id)
|
||||
{
|
||||
$pathinfo = pathinfo($v);
|
||||
|
||||
$ext = isset($pathinfo['extension']) ? $pathinfo['extension'] : '';
|
||||
|
||||
$image = isset($pathinfo['filename']) ? $pathinfo['filename'] : '';
|
||||
|
||||
$product->mImageFiles = array();
|
||||
|
||||
$this->getLogger()->info(sprintf('Przenosze zdjęcia z produktu o id "%s" do produktu o kodzie "%s"', $user_id, $product->getCode()));
|
||||
|
||||
if (strtolower($ext) == 'jpg' || strtolower($ext) == 'gif' || strtolower($ext) == 'png')
|
||||
{
|
||||
for($i = 0; $i <= 10; $i++)
|
||||
{
|
||||
$filename = stMigrationSoteshopHelper::fixString($image) . ($i ? '-' . $i : '') . '.' . $ext;
|
||||
|
||||
$url_filename = rawurlencode($image) . ($i ? '-' . $i : '') . '.' . $ext;
|
||||
|
||||
$image_path = $this->uploadImage($this->getMigrationParam('www') . '/photo/' . $url_filename);
|
||||
|
||||
if ($image_path)
|
||||
{
|
||||
$product->mImageFiles[] = $image_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getLogger()->notice('Produkt nie zawiera zdjęć...');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMGroup($product, $main_page, $bestseller, $promotion)
|
||||
{
|
||||
if (!empty($main_page))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'MAIN_PAGE');
|
||||
}
|
||||
|
||||
if (!empty($promotion))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'PROMOTION');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMCategoryMulti($product, $category_multi_1, $category_multi_2)
|
||||
{
|
||||
if (!empty($category_multi_1))
|
||||
{
|
||||
$categories = explode("/", $category_multi_1);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
if (!empty($category_multi_2))
|
||||
{
|
||||
$categories = explode("/", $category_multi_2);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $product
|
||||
*/
|
||||
public function setMCategory($product, $categories)
|
||||
{
|
||||
$category = $this->categoryWalk(array_values($categories));
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
public function setMPrice($product, $price_brutto, $vat)
|
||||
{
|
||||
$product->setPriceNettoByBrutto($price_brutto, $vat);
|
||||
}
|
||||
|
||||
public function setMProductOptions($product, $xml_options)
|
||||
{
|
||||
$this->mProductOptions = $xml_options;
|
||||
}
|
||||
|
||||
protected function addProductOptions($product, $xml_options, $con = null)
|
||||
{
|
||||
if (!empty($xml_options))
|
||||
{
|
||||
$root = new ProductOptionsValue();
|
||||
|
||||
$root->makeRoot();
|
||||
|
||||
$root->setProduct($product);
|
||||
|
||||
$root->setCulture('pl_PL');
|
||||
|
||||
$root->save();
|
||||
|
||||
$attributes = stMigrationSoteshopHelper::xmlOptionsToArray($xml_options);
|
||||
|
||||
$this->addProductOptionsRecursive($product, $attributes, $root, $con);
|
||||
}
|
||||
}
|
||||
|
||||
protected function addProductOptionsRecursive($product, $attributes, $root, $con = null)
|
||||
{
|
||||
if (!is_array($attributes)) return;
|
||||
|
||||
foreach ($attributes as $name => $options)
|
||||
{
|
||||
$pof = new ProductOptionsField();
|
||||
|
||||
$pof->setCulture('pl_PL');
|
||||
|
||||
$pof->setName($name);
|
||||
|
||||
$pof->save($con);
|
||||
|
||||
foreach ($options as $name => $params)
|
||||
{
|
||||
// $root = $root->reload();
|
||||
|
||||
$pov = new ProductOptionsValue();
|
||||
|
||||
$pov->setCulture('pl_PL');
|
||||
|
||||
$pov->setProduct($product);
|
||||
|
||||
$pov->setProductOptionsField($pof);
|
||||
|
||||
$pov->setValue($name);
|
||||
|
||||
$pov->setPrice($params['price']);
|
||||
|
||||
$pov->insertAsLastChildOf($root);
|
||||
|
||||
$pov->save($con);
|
||||
|
||||
$root->setRgt($pov->getRgt()+1);
|
||||
|
||||
// $this->addProductOptionsRecursive($product, $params['nested'], $pov, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function categoryWalk($path)
|
||||
{
|
||||
$tmp = $this->getRootCategory();
|
||||
|
||||
if (is_null($tmp))
|
||||
{
|
||||
$tmp = new Category();
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
$tmp->setName('Kategorie');
|
||||
|
||||
$tmp->makeRoot();
|
||||
|
||||
$tmp->save();
|
||||
|
||||
$tmp->setScope($tmp->getId());
|
||||
|
||||
$tmp->save();
|
||||
}
|
||||
|
||||
$tmp = $tmp->reload();
|
||||
|
||||
$count = count($path);
|
||||
|
||||
for($i = 0; $i < $count && !empty($path[$i]); $i++)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryI18nPeer::NAME, $path[$i]);
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, $tmp->getId());
|
||||
|
||||
$c->add(CategoryI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$category = CategoryPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($category[0]))
|
||||
break;
|
||||
|
||||
$tmp = $category[0];
|
||||
}
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
for($j = $i; $j < $count && !empty($path[$j]); $j++)
|
||||
{
|
||||
|
||||
$category = new Category();
|
||||
|
||||
$category->setCulture('pl_PL');
|
||||
|
||||
$category->setName($path[$j]);
|
||||
|
||||
$category->insertAsLastChildOf($tmp);
|
||||
|
||||
$category->save();
|
||||
|
||||
$tmp = $category;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function getRootCategory()
|
||||
{
|
||||
if (is_null($this->rootCategory))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, null, Criteria::ISNULL);
|
||||
|
||||
$this->rootCategory = CategoryPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
return $this->rootCategory;
|
||||
}
|
||||
|
||||
protected function getProductGroupByType($type = 'MAIN_PAGE')
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductGroupPeer::PRODUCT_GROUP, $type);
|
||||
|
||||
return ProductGroupPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
protected function addProductToGroupType($product, $group_type = 'MAIN_PAGE')
|
||||
{
|
||||
$product_group = $this->getProductGroupByType($group_type);
|
||||
|
||||
$product_group_has_product = new ProductGroupHasProduct();
|
||||
|
||||
$product_group_has_product->setProduct($product);
|
||||
|
||||
$product_group_has_product->setProductGroup($product_group);
|
||||
|
||||
$product->addProductGroupHasProduct($product_group_has_product);
|
||||
}
|
||||
|
||||
protected function addProductToCategory($product, $category)
|
||||
{
|
||||
$product_has_category = new ProductHasCategory();
|
||||
|
||||
$product_has_category->setCategory($category);
|
||||
|
||||
$product->addProductHasCategory($product_has_category);
|
||||
}
|
||||
|
||||
protected function addImageToProduct($product, $image, $default = false, $con = null)
|
||||
{
|
||||
$product_has_asset = new ProductHasSfAsset();
|
||||
|
||||
$product_has_asset->setIsDefault($default);
|
||||
|
||||
$product_has_asset->setProduct($product);
|
||||
|
||||
$product_has_asset->createAsset(basename($image), $image, ProductHasSfAssetPeer::IMAGE_FOLDER);
|
||||
|
||||
$product_has_asset->save($con);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationReview.class.php 16984 2012-02-07 12:00:51Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationReview extends stMigrationSoteshopReviewBase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationsfGuardUser.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationsfGuardUser extends stMigrationSoteshopGuardUserModel
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationOrder.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationOrder extends stMigrationSoteshopOrderBase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,491 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationProduct.class.php 13946 2011-07-05 13:22:43Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationProduct extends stMigrationModel
|
||||
{
|
||||
|
||||
protected $rootCategory = null;
|
||||
protected $mProductOptions = null;
|
||||
protected $mWholesale = null;
|
||||
|
||||
public function preSave($product, $con = null)
|
||||
{
|
||||
$product->setCulture(stLanguage::getOptLanguage());
|
||||
}
|
||||
|
||||
public function postSave($product, $con = null)
|
||||
{
|
||||
|
||||
$default = true;
|
||||
|
||||
foreach ($product->mImageFiles as $image)
|
||||
{
|
||||
$this->addImageToProduct($product, $image, $default, $con);
|
||||
|
||||
$default = false;
|
||||
}
|
||||
|
||||
$this->addProductOptions($product, $this->mProductOptions, $con);
|
||||
}
|
||||
|
||||
public function setMPositioning($product, $title, $keywords, $description)
|
||||
{
|
||||
if ($title && $keywords && $description)
|
||||
{
|
||||
$php = new ProductHasPositioning();
|
||||
|
||||
$php->setCulture('pl_PL');
|
||||
|
||||
|
||||
$php->setTitle($title);
|
||||
|
||||
$php->setKeywords($keywords);
|
||||
|
||||
$php->setDescription($description);
|
||||
|
||||
|
||||
$product->addProductHasPositioning($php);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMCode($product, $v)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductPeer::CODE, $v);
|
||||
|
||||
$count = ProductPeer::doCount($c);
|
||||
|
||||
$product->setCode($count ? 'DUPLICATE_'.$count.'_'.$v : $v);
|
||||
}
|
||||
|
||||
public function setMVat($product, $v)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(TaxPeer::VAT, $v);
|
||||
|
||||
$tax = TaxPeer::doSelectOne($c);
|
||||
|
||||
if (is_null($tax))
|
||||
{
|
||||
$tax = new Tax();
|
||||
|
||||
$tax->setVat($v);
|
||||
}
|
||||
|
||||
$product->setOptVat($v);
|
||||
|
||||
$product->setTax($tax);
|
||||
}
|
||||
|
||||
public function setMProducer($product, $v)
|
||||
{
|
||||
if (!empty($v))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProducerI18nPeer::NAME, $v);
|
||||
|
||||
$c->add(ProducerI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$producer = ProducerPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($producer[0]))
|
||||
{
|
||||
$producer = new Producer();
|
||||
|
||||
$producer->setCulture('pl_PL');
|
||||
|
||||
$producer->setName($v);
|
||||
}
|
||||
else
|
||||
{
|
||||
$producer = $producer[0];
|
||||
}
|
||||
|
||||
$product->setProducer($producer);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMName($product, $names)
|
||||
{
|
||||
$names = array_values($names);
|
||||
|
||||
$count = count($names);
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($names[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setName($names[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMDescription($product, $descriptions)
|
||||
{
|
||||
$descriptions = array_values($descriptions);
|
||||
|
||||
$count = count($descriptions);
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($descriptions[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setDescription($descriptions[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMShortDescription($product, $descriptions)
|
||||
{
|
||||
$descriptions = array_values($descriptions);
|
||||
|
||||
$count = count($descriptions);
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($descriptions[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setShortDescription($descriptions[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMImage($product, $v, $user_id)
|
||||
{
|
||||
$pathinfo = pathinfo($v);
|
||||
|
||||
$ext = isset($pathinfo['extension']) ? $pathinfo['extension'] : '';
|
||||
|
||||
$image = isset($pathinfo['filename']) ? $pathinfo['filename'] : '';
|
||||
|
||||
$product->mImageFiles = array();
|
||||
|
||||
$this->getLogger()->info(sprintf('Przenosze zdjęcia z produktu o id "%s" do produktu o kodzie "%s"', $user_id, $product->getCode()));
|
||||
|
||||
if (strtolower($ext) == 'jpg' || strtolower($ext) == 'gif' || strtolower($ext) == 'png')
|
||||
{
|
||||
for ($i = 0; $i <= 10; $i++)
|
||||
{
|
||||
$filename = stMigrationSoteshopHelper::fixString($image).($i ? '-'.$i : '').'.'.$ext;
|
||||
|
||||
$url_filename = rawurlencode($image).($i ? '-'.$i : '').'.'.$ext;
|
||||
|
||||
$image_path = $this->uploadImage($this->getMigrationParam('www').'/photo/'.$url_filename);
|
||||
|
||||
if ($image_path)
|
||||
{
|
||||
$product->mImageFiles[] = $image_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getLogger()->notice('Produkt nie zawiera zdjęć...');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMGroup($product, $main_page, $bestseller, $promotion)
|
||||
{
|
||||
if (!empty($main_page))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'MAIN_PAGE');
|
||||
}
|
||||
|
||||
if (!empty($promotion))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'PROMOTION');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMCategoryMulti($product, $category_multi_1, $category_multi_2)
|
||||
{
|
||||
if (!empty($category_multi_1))
|
||||
{
|
||||
$categories = explode("/", $category_multi_1);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
if (!empty($category_multi_2))
|
||||
{
|
||||
$categories = explode("/", $category_multi_2);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $product
|
||||
*/
|
||||
public function setMCategory($product, $categories)
|
||||
{
|
||||
$category = $this->categoryWalk(array_values($categories));
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
public function setMPrice($product, $price_brutto, $vat)
|
||||
{
|
||||
$product->setPriceNettoByBrutto($price_brutto, $vat);
|
||||
}
|
||||
|
||||
public function setMProductOptions($product, $xml_options)
|
||||
{
|
||||
$this->mProductOptions = $xml_options;
|
||||
}
|
||||
|
||||
protected function addProductOptions($product, $xml_options, $con = null)
|
||||
{
|
||||
if (!empty($xml_options))
|
||||
{
|
||||
$root = new ProductOptionsValue();
|
||||
|
||||
$root->makeRoot();
|
||||
|
||||
$root->setProduct($product);
|
||||
|
||||
$root->setCulture('pl_PL');
|
||||
|
||||
$root->save($con);
|
||||
|
||||
$attributes = stMigrationSoteshopHelper::xmlOptionsToArray($xml_options);
|
||||
|
||||
$this->addProductOptionsRecursive($product, $attributes, $root, $con);
|
||||
}
|
||||
}
|
||||
|
||||
protected function addProductOptionsRecursive($product, $attributes, $root, $con = null)
|
||||
{
|
||||
if (!is_array($attributes))
|
||||
return;
|
||||
|
||||
foreach ($attributes as $name => $options)
|
||||
{
|
||||
$pof = new ProductOptionsField();
|
||||
|
||||
$pof->setCulture('pl_PL');
|
||||
|
||||
$pof->setName($name);
|
||||
|
||||
$pof->save($con);
|
||||
|
||||
foreach ($options as $name => $params)
|
||||
{
|
||||
// $root = $root->reload();
|
||||
|
||||
$pov = new ProductOptionsValue();
|
||||
|
||||
$pov->setCulture('pl_PL');
|
||||
|
||||
$pov->setProduct($product);
|
||||
|
||||
$pov->setProductOptionsField($pof);
|
||||
|
||||
$pov->setValue($name);
|
||||
|
||||
$pov->setPrice($params['price']);
|
||||
|
||||
$pov->setSfAssetId(isset($product->imageNo2Asset[$params['image']]) ? $product->imageNo2Asset[$params['image']] : null);
|
||||
|
||||
$pov->insertAsLastChildOf($root);
|
||||
|
||||
$pov->save($con);
|
||||
|
||||
$root->setRgt($pov->getRgt()+1);
|
||||
|
||||
// $this->addProductOptionsRecursive($product, $params['nested'], $pov, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function categoryWalk($path, $ids = array())
|
||||
{
|
||||
$tmp = $this->getRootCategory();
|
||||
|
||||
if (is_null($tmp))
|
||||
{
|
||||
$tmp = new Category();
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
$tmp->setName('Kategorie');
|
||||
|
||||
$tmp->makeRoot();
|
||||
|
||||
$tmp->save();
|
||||
|
||||
$tmp->setScope($tmp->getId());
|
||||
|
||||
$tmp->save();
|
||||
}
|
||||
|
||||
$tmp = $tmp->reload();
|
||||
|
||||
$count = count($path);
|
||||
|
||||
for ($i = 0; $i < $count && !empty($path[$i]); $i++)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryI18nPeer::NAME, $path[$i]);
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, $tmp->getId());
|
||||
|
||||
$c->add(CategoryI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$category = CategoryPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($category[0]))
|
||||
break;
|
||||
|
||||
$tmp = $category[0];
|
||||
}
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
for ($j = $i; $j < $count && !empty($path[$j]); $j++)
|
||||
{
|
||||
|
||||
$category = new Category();
|
||||
|
||||
$category->setCulture('pl_PL');
|
||||
|
||||
$category->setName($path[$j]);
|
||||
|
||||
$dictionary = $this->getDictionary($path[$j]);
|
||||
|
||||
if ($dictionary)
|
||||
{
|
||||
foreach ($dictionary as $culture => $name) {
|
||||
if ($name)
|
||||
{
|
||||
$category->setCulture($culture);
|
||||
$category->setName($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$category->insertAsLastChildOf($tmp);
|
||||
|
||||
$category->setCulture(stLanguage::getOptLanguage());
|
||||
|
||||
$category->save();
|
||||
|
||||
if (isset($ids[$j]))
|
||||
{
|
||||
$this->addCategoryPositioning($category, $ids[$j]);
|
||||
}
|
||||
|
||||
$tmp = $category;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function getRootCategory()
|
||||
{
|
||||
if (is_null($this->rootCategory))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, null, Criteria::ISNULL);
|
||||
|
||||
$this->rootCategory = CategoryPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
return $this->rootCategory;
|
||||
}
|
||||
|
||||
protected function getProductGroupByType($type = 'MAIN_PAGE')
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductGroupPeer::PRODUCT_GROUP, $type);
|
||||
|
||||
return ProductGroupPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
protected function addProductToGroupType($product, $group_type = 'MAIN_PAGE')
|
||||
{
|
||||
$product_group = $this->getProductGroupByType($group_type);
|
||||
|
||||
$product_group_has_product = new ProductGroupHasProduct();
|
||||
|
||||
$product_group_has_product->setProduct($product);
|
||||
|
||||
$product_group_has_product->setProductGroup($product_group);
|
||||
|
||||
$product->addProductGroupHasProduct($product_group_has_product);
|
||||
}
|
||||
|
||||
protected function addProductToCategory($product, $category)
|
||||
{
|
||||
$product_has_category = new ProductHasCategory();
|
||||
|
||||
$product_has_category->setCategory($category);
|
||||
|
||||
$product->addProductHasCategory($product_has_category);
|
||||
}
|
||||
|
||||
protected function addImageToProduct($product, $image, $default = false, $con = null)
|
||||
{
|
||||
$product_has_asset = new ProductHasSfAsset();
|
||||
|
||||
$product_has_asset->setIsDefault($default);
|
||||
|
||||
$product_has_asset->setProduct($product);
|
||||
|
||||
$filename = basename($image);
|
||||
|
||||
$product_has_asset->createAsset($filename, $image, ProductHasSfAssetPeer::IMAGE_FOLDER);
|
||||
|
||||
$product_has_asset->save($con);
|
||||
|
||||
$product->imageNo2Asset[$filename] = $product_has_asset->getSfAssetId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationReview.class.php 16984 2012-02-07 12:00:51Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationReview extends stMigrationSoteshopReviewBase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationsfGuardUser.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationsfGuardUser extends stMigrationSoteshopGuardUserModel
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationOrder.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationOrder extends stMigrationSoteshopOrderBase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,611 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationProduct.class.php 16984 2012-02-07 12:00:51Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationProduct extends stMigrationModel
|
||||
{
|
||||
|
||||
protected $rootCategory = null;
|
||||
protected $mProductOptions = null;
|
||||
protected $mUserId = null;
|
||||
protected $mWholesale = null;
|
||||
|
||||
public function preSave($product, $con = null)
|
||||
{
|
||||
$product->setCulture(stLanguage::getOptLanguage());
|
||||
}
|
||||
|
||||
public function postSave($product, $con = null)
|
||||
{
|
||||
$default = true;
|
||||
|
||||
foreach ($product->mImageFiles as $image)
|
||||
{
|
||||
$this->addImageToProduct($product, $image, $default, $con);
|
||||
|
||||
$default = false;
|
||||
}
|
||||
|
||||
$this->addProductOptions($product, $this->mProductOptions, $this->mUserId, $con);
|
||||
}
|
||||
|
||||
public function setMPositioning($product, $title, $keywords, $description)
|
||||
{
|
||||
if ($title && $keywords && $description)
|
||||
{
|
||||
$php = new ProductHasPositioning();
|
||||
|
||||
$php->setCulture('pl_PL');
|
||||
|
||||
|
||||
$php->setTitle($title);
|
||||
|
||||
$php->setKeywords($keywords);
|
||||
|
||||
$php->setDescription($description);
|
||||
|
||||
|
||||
$product->addProductHasPositioning($php);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMCode($product, $v)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductPeer::CODE, $v);
|
||||
|
||||
$count = ProductPeer::doCount($c);
|
||||
|
||||
$product->setCode($count ? 'DUPLICATE_'.$count.'_'.$v : $v);
|
||||
}
|
||||
|
||||
public function setMVat($product, $v)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(TaxPeer::VAT, $v);
|
||||
|
||||
$tax = TaxPeer::doSelectOne($c);
|
||||
|
||||
if (is_null($tax))
|
||||
{
|
||||
$tax = new Tax();
|
||||
|
||||
$tax->setVat($v);
|
||||
}
|
||||
|
||||
$product->setOptVat($v);
|
||||
|
||||
$product->setTax($tax);
|
||||
}
|
||||
|
||||
public function setMProducer($product, $v)
|
||||
{
|
||||
if (!empty($v))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProducerI18nPeer::NAME, $v);
|
||||
|
||||
$c->add(ProducerI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$producer = ProducerPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($producer[0]))
|
||||
{
|
||||
$producer = new Producer();
|
||||
|
||||
$producer->setCulture('pl_PL');
|
||||
|
||||
$producer->setName($v);
|
||||
}
|
||||
else
|
||||
{
|
||||
$producer = $producer[0];
|
||||
}
|
||||
|
||||
$product->setProducer($producer);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMName($product, $names)
|
||||
{
|
||||
$names = array_values($names);
|
||||
|
||||
$count = count($names);
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($names[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setName($names[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMDescription($product, $descriptions)
|
||||
{
|
||||
$descriptions = array_values($descriptions);
|
||||
|
||||
$count = count($descriptions);
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($descriptions[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setDescription($descriptions[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMShortDescription($product, $descriptions)
|
||||
{
|
||||
$descriptions = array_values($descriptions);
|
||||
|
||||
$count = count($descriptions);
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($descriptions[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setShortDescription($descriptions[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMImage($product, $photo_uid, $photo_count, $default_photo, $user_id)
|
||||
{
|
||||
$product->mImageFiles = array();
|
||||
|
||||
$this->getLogger()->info(sprintf('Przenosze zdjęcia z produktu o id "%s" do produktu o kodzie "%s"', $user_id, $product->getCode()));
|
||||
|
||||
if (!empty($photo_uid) && $photo_count > 0)
|
||||
{
|
||||
for ($i = 1; $i <= $photo_count; $i++)
|
||||
{
|
||||
$filename = $i.'_'.$photo_uid.'.jpg';
|
||||
|
||||
$url_path = $photo_uid[0].'/'.$photo_uid[1].'/'.$photo_uid[2];
|
||||
|
||||
$image = $this->uploadImage($this->getMigrationParam('www').'/photo/product_orig/'.$url_path.'/'.$filename);
|
||||
|
||||
if ($image)
|
||||
{
|
||||
$product->mImageFiles[] = $image;
|
||||
}
|
||||
|
||||
usleep(200000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getLogger()->notice('Produkt nie zawiera zdjęć...');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMGroup($product, $main_page, $bestseller, $promotion)
|
||||
{
|
||||
if (!empty($main_page))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'MAIN_PAGE');
|
||||
}
|
||||
|
||||
if (!empty($promotion))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'PROMOTION');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMCategoryMulti($product, $category_multi_1, $category_multi_2)
|
||||
{
|
||||
if (!empty($category_multi_1))
|
||||
{
|
||||
$categories = explode("/", $category_multi_1);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
if (!empty($category_multi_2))
|
||||
{
|
||||
$categories = explode("/", $category_multi_2);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $product
|
||||
*/
|
||||
public function setMCategory($product, $categories, $ids)
|
||||
{
|
||||
$category = $this->categoryWalk(array_values($categories), array_values($ids));
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Product $product Product
|
||||
* @param <type> $price_brutto
|
||||
* @param <type> $vat
|
||||
*/
|
||||
public function setMPrice($product, $price_brutto, $vat)
|
||||
{
|
||||
$product->setPriceNettoByBrutto($price_brutto, $vat);
|
||||
}
|
||||
|
||||
public function setMProductOptions($product, $xml_options, $user_id)
|
||||
{
|
||||
$this->mProductOptions = $xml_options;
|
||||
|
||||
$this->mUserId = $user_id;
|
||||
}
|
||||
|
||||
protected function getProductOptionsStock($code)
|
||||
{
|
||||
$options_stock = array();
|
||||
|
||||
$data_retriever = $this->getDataRetriever();
|
||||
|
||||
$stmt = $data_retriever->prepareStatement("SELECT adv_attr, num AS stock FROM depository WHERE user_id_main = ? AND adv_attr != '*' AND adv_attr is NOT NULL");
|
||||
|
||||
$stmt->setString(1, $code);
|
||||
|
||||
$rs = $stmt->executeQuery();
|
||||
|
||||
while ($rs->next())
|
||||
{
|
||||
$stock = $rs->getInt('stock');
|
||||
|
||||
$tmp = explode(',', $rs->getString('adv_attr'));
|
||||
|
||||
$this->parseProductOptionsStock($options_stock, $tmp, $stock);
|
||||
}
|
||||
|
||||
return $options_stock;
|
||||
}
|
||||
|
||||
protected function parseProductOptionsStock(&$options_stock, $adv_attr, $stock, $index = 0)
|
||||
{
|
||||
if (isset($adv_attr[$index]))
|
||||
{
|
||||
$key = $adv_attr[$index];
|
||||
|
||||
if (!isset($options_stock[$key]))
|
||||
{
|
||||
$options_stock[$key] = array();
|
||||
}
|
||||
|
||||
$this->parseProductOptionsStock($options_stock[$key], $adv_attr, $stock, $index + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$options_stock = $stock;
|
||||
}
|
||||
}
|
||||
|
||||
protected function addProductOptions($product, $xml_options, $code, $con = null)
|
||||
{
|
||||
if (!empty($xml_options))
|
||||
{
|
||||
$root = new ProductOptionsValue();
|
||||
|
||||
$root->makeRoot();
|
||||
|
||||
$root->setProduct($product);
|
||||
|
||||
$root->setCulture('pl_PL');
|
||||
|
||||
$root->save($con);
|
||||
|
||||
// $options_stock = $this->getProductOptionsStock($code);
|
||||
|
||||
$attributes = stMigrationSoteshopHelper::xmlOptionsToArray($xml_options);
|
||||
|
||||
$this->addProductOptionsRecursive($product, $attributes, array(), $root, $con);
|
||||
}
|
||||
}
|
||||
|
||||
protected function addProductOptionsRecursive($product, $attributes, $options_stock, $root, $con = null)
|
||||
{
|
||||
if (!is_array($attributes))
|
||||
return;
|
||||
|
||||
foreach ($attributes as $name => $options)
|
||||
{
|
||||
$pof = new ProductOptionsField();
|
||||
|
||||
$pof->setCulture('pl_PL');
|
||||
|
||||
$pof->setName($name);
|
||||
|
||||
$pof->save($con);
|
||||
|
||||
foreach ($options as $name => $params)
|
||||
{
|
||||
// $root = $root->reload();
|
||||
|
||||
// $stock_name = isset($options_stock[$name]) ? $name : '*';
|
||||
|
||||
// $stock = isset($options_stock[$stock_name]) && is_numeric($options_stock[$stock_name]) ? $options_stock[$stock_name] : null;
|
||||
|
||||
$pov = new ProductOptionsValue();
|
||||
|
||||
$pov->setCulture('pl_PL');
|
||||
|
||||
$pov->setProduct($product);
|
||||
|
||||
$pov->setProductOptionsField($pof);
|
||||
|
||||
$pov->setValue($name);
|
||||
|
||||
// $pov->setStock($stock);
|
||||
//
|
||||
// if ($stock)
|
||||
// {
|
||||
// $product->setStock($product->getStock() + $stock);
|
||||
// }
|
||||
|
||||
$pov->setPrice($params['price']);
|
||||
|
||||
$pov->setSfAssetId(isset($product->imageNo2Asset[$params['image']]) ? $product->imageNo2Asset[$params['image']] : null);
|
||||
|
||||
$pov->insertAsLastChildOf($root);
|
||||
|
||||
$pov->save($con);
|
||||
|
||||
$root->setRgt($pov->getRgt()+1);
|
||||
|
||||
// $this->addProductOptionsRecursive($product, $params['nested'], isset($options_stock[$stock_name]) && is_array($options_stock[$stock_name]) ? $options_stock[$stock_name] : array(), $pov);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function addOrderProduct($order)
|
||||
{
|
||||
$data_procesor = new stMigrationDataProcesor();
|
||||
|
||||
$data_retriever = $this->getDataRetriever();
|
||||
|
||||
$model_fillin = $this->getOrderProductFillin();
|
||||
|
||||
$stmt = $data_retriever->prepareStatement('SELECT * FROM order_products WHERE order_id = ?');
|
||||
|
||||
$stmt->setInt(1, $this->mId);
|
||||
|
||||
$stmt->setLimit(0);
|
||||
|
||||
$rs = $stmt->executeQuery();
|
||||
|
||||
$data_procesor->setModelClass('OrderProduct');
|
||||
|
||||
$data_procesor->setModelFillin($model_fillin);
|
||||
|
||||
$data_procesor->setModelParams(array('order' => $order));
|
||||
|
||||
$data_procesor->autoSaveModel(false);
|
||||
|
||||
while ($rs->next())
|
||||
{
|
||||
$data_procesor->process($rs->getRow());
|
||||
}
|
||||
}
|
||||
|
||||
protected function addCategoryPositioning(Category $category, $source_id)
|
||||
{
|
||||
$data_retriever = $this->getDataRetriever();
|
||||
|
||||
$stmt = $data_retriever->prepareStatement('SELECT * FROM category'.$category->getDepth().' WHERE id = ?');
|
||||
|
||||
$stmt->setInt(1, $source_id);
|
||||
|
||||
$stmt->setLimit(1);
|
||||
|
||||
$rs = $stmt->executeQuery();
|
||||
|
||||
if ($rs->next())
|
||||
{
|
||||
if ($title = $rs->getString('title'))
|
||||
{
|
||||
$chp = new CategoryHasPositioning();
|
||||
|
||||
$chp->setCulture('pl_PL');
|
||||
|
||||
$chp->setCategoryId($category->getId());
|
||||
|
||||
$chp->setTitle($title);
|
||||
|
||||
$chp->setKeywords($rs->getString('keywords'));
|
||||
|
||||
$chp->setDescription($rs->getString('description'));
|
||||
|
||||
$chp->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function categoryWalk($path, $ids = array())
|
||||
{
|
||||
$tmp = $this->getRootCategory();
|
||||
|
||||
if (is_null($tmp))
|
||||
{
|
||||
$tmp = new Category();
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
$tmp->setName('Kategorie');
|
||||
|
||||
$tmp->makeRoot();
|
||||
|
||||
$tmp->save();
|
||||
|
||||
$tmp->setScope($tmp->getId());
|
||||
|
||||
$tmp->save();
|
||||
}
|
||||
|
||||
$tmp = $tmp->reload();
|
||||
|
||||
$count = count($path);
|
||||
|
||||
for ($i = 0; $i < $count && !empty($path[$i]); $i++)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryI18nPeer::NAME, $path[$i]);
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, $tmp->getId());
|
||||
|
||||
$c->add(CategoryI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$category = CategoryPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($category[0]))
|
||||
break;
|
||||
|
||||
$tmp = $category[0];
|
||||
}
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
for ($j = $i; $j < $count && !empty($path[$j]); $j++)
|
||||
{
|
||||
|
||||
$category = new Category();
|
||||
|
||||
$category->setCulture('pl_PL');
|
||||
|
||||
$category->setName($path[$j]);
|
||||
|
||||
$dictionary = $this->getDictionary($path[$j]);
|
||||
|
||||
if ($dictionary)
|
||||
{
|
||||
foreach ($dictionary as $culture => $name) {
|
||||
if ($name)
|
||||
{
|
||||
$category->setCulture($culture);
|
||||
$category->setName($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$category->insertAsLastChildOf($tmp);
|
||||
|
||||
$category->setCulture(stLanguage::getOptLanguage());
|
||||
|
||||
$category->save();
|
||||
|
||||
if (isset($ids[$j]))
|
||||
{
|
||||
$this->addCategoryPositioning($category, $ids[$j]);
|
||||
}
|
||||
|
||||
$tmp = $category;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function getRootCategory()
|
||||
{
|
||||
if (is_null($this->rootCategory))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, null, Criteria::ISNULL);
|
||||
|
||||
$this->rootCategory = CategoryPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
return $this->rootCategory;
|
||||
}
|
||||
|
||||
protected function getProductGroupByType($type = 'MAIN_PAGE')
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductGroupPeer::PRODUCT_GROUP, $type);
|
||||
|
||||
return ProductGroupPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
protected function addProductToGroupType($product, $group_type = 'MAIN_PAGE')
|
||||
{
|
||||
$product_group = $this->getProductGroupByType($group_type);
|
||||
|
||||
$product_group_has_product = new ProductGroupHasProduct();
|
||||
|
||||
$product_group_has_product->setProduct($product);
|
||||
|
||||
$product_group_has_product->setProductGroup($product_group);
|
||||
|
||||
$product->addProductGroupHasProduct($product_group_has_product);
|
||||
}
|
||||
|
||||
protected function addProductToCategory($product, $category)
|
||||
{
|
||||
$product_has_category = new ProductHasCategory();
|
||||
|
||||
$product_has_category->setCategory($category);
|
||||
|
||||
$product->addProductHasCategory($product_has_category);
|
||||
}
|
||||
|
||||
protected function addImageToProduct($product, $image, $default = false, $con = null)
|
||||
{
|
||||
$product_has_asset = new ProductHasSfAsset();
|
||||
|
||||
$product_has_asset->setIsDefault($default);
|
||||
|
||||
$product_has_asset->setProduct($product);
|
||||
|
||||
$filename = basename($image);
|
||||
|
||||
list($image_no) = explode('_', $filename);
|
||||
|
||||
$product_has_asset->createAsset($filename, $image, ProductHasSfAssetPeer::IMAGE_FOLDER);
|
||||
|
||||
$product_has_asset->save($con);
|
||||
|
||||
$product->imageNo2Asset[$image_no] = $product_has_asset->getSfAssetId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationReview.class.php 16984 2012-02-07 12:00:51Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationReview extends stMigrationModel
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param Review $review
|
||||
*/
|
||||
public function postCreate($review)
|
||||
{
|
||||
$review->setActive(true);
|
||||
|
||||
$review->setAdminActive(true);
|
||||
|
||||
$review->setAgreement(true);
|
||||
|
||||
$review->setLanguage('pl_PL');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Review $review
|
||||
* @param string $user_id Id produktu nadane przez administratora
|
||||
*/
|
||||
public function setMProductId($review, $user_id)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductPeer::CODE, stMigrationSoteshopHelper::fixString($user_id));
|
||||
|
||||
$product = ProductPeer::doSelectOne($c);
|
||||
|
||||
$review->setProductId($product ? $product->getId() : null);
|
||||
|
||||
unset($product);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationsfGuardUser.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationsfGuardUser extends stMigrationSoteshopGuardUserModel
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationOrder.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationOrder extends stMigrationSoteshopOrderBase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationProduct.class.php 16984 2012-02-07 12:00:51Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationProduct extends stMigrationModel
|
||||
{
|
||||
|
||||
protected $rootCategory = null;
|
||||
protected $mProductOptions = null;
|
||||
protected $mUserId = null;
|
||||
protected $mWholesale = null;
|
||||
|
||||
public function preSave($product, $con = null)
|
||||
{
|
||||
$product->setCulture(stLanguage::getOptLanguage());
|
||||
}
|
||||
|
||||
public function postSave($product, $con = null)
|
||||
{
|
||||
$default = true;
|
||||
|
||||
foreach ($product->mImageFiles as $image)
|
||||
{
|
||||
$this->addImageToProduct($product, $image, $default, $con);
|
||||
|
||||
$default = false;
|
||||
}
|
||||
|
||||
$this->addProductOptions($product, $this->mProductOptions, $this->mUserId, $con);
|
||||
}
|
||||
|
||||
public function setMPositioning($product, $title, $keywords, $description)
|
||||
{
|
||||
if ($title && $keywords && $description)
|
||||
{
|
||||
$php = new ProductHasPositioning();
|
||||
|
||||
$php->setCulture('pl_PL');
|
||||
|
||||
|
||||
$php->setTitle($title);
|
||||
|
||||
$php->setKeywords($keywords);
|
||||
|
||||
$php->setDescription($description);
|
||||
|
||||
|
||||
$product->addProductHasPositioning($php);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMCode($product, $v)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductPeer::CODE, $v);
|
||||
|
||||
$count = ProductPeer::doCount($c);
|
||||
|
||||
$product->setCode($count ? 'DUPLICATE_'.$count.'_'.$v : $v);
|
||||
}
|
||||
|
||||
public function setMVat($product, $v)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(TaxPeer::VAT, $v);
|
||||
|
||||
$tax = TaxPeer::doSelectOne($c);
|
||||
|
||||
if (is_null($tax))
|
||||
{
|
||||
$tax = new Tax();
|
||||
|
||||
$tax->setVat($v);
|
||||
}
|
||||
|
||||
$product->setOptVat($v);
|
||||
|
||||
$product->setTax($tax);
|
||||
}
|
||||
|
||||
public function setMProducer($product, $v)
|
||||
{
|
||||
if (!empty($v))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProducerI18nPeer::NAME, $v);
|
||||
|
||||
$c->add(ProducerI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$producer = ProducerPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($producer[0]))
|
||||
{
|
||||
$producer = new Producer();
|
||||
|
||||
$producer->setCulture('pl_PL');
|
||||
|
||||
$producer->setName($v);
|
||||
}
|
||||
else
|
||||
{
|
||||
$producer = $producer[0];
|
||||
}
|
||||
|
||||
$product->setProducer($producer);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMName($product, $names)
|
||||
{
|
||||
$names = array_values($names);
|
||||
|
||||
$count = count($names);
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($names[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setName($names[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMDescription($product, $descriptions)
|
||||
{
|
||||
$descriptions = array_values($descriptions);
|
||||
|
||||
$count = count($descriptions);
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($descriptions[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setDescription($descriptions[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMShortDescription($product, $descriptions)
|
||||
{
|
||||
$descriptions = array_values($descriptions);
|
||||
|
||||
$count = count($descriptions);
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (!empty($descriptions[$i]))
|
||||
{
|
||||
$culture = stMigrationSoteshopHelper::getCultureByLangId($i);
|
||||
|
||||
$product->setCulture($culture);
|
||||
|
||||
$product->setShortDescription($descriptions[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMImage($product, $photo_uid, $photo_count, $default_photo, $user_id)
|
||||
{
|
||||
$product->mImageFiles = array();
|
||||
|
||||
$this->getLogger()->info(sprintf('Przenosze zdjęcia z produktu o id "%s" do produktu o kodzie "%s"', $user_id, $product->getCode()));
|
||||
|
||||
if (!empty($photo_uid) && $photo_count > 0)
|
||||
{
|
||||
for ($i = 1; $i <= $photo_count; $i++)
|
||||
{
|
||||
$filename = $i.'_'.$photo_uid.'.jpg';
|
||||
|
||||
$url_path = $photo_uid[0].'/'.$photo_uid[1].'/'.$photo_uid[2];
|
||||
|
||||
$image = $this->uploadImage($this->getMigrationParam('www').'/photo/product_orig/'.$url_path.'/'.$filename);
|
||||
|
||||
if ($image)
|
||||
{
|
||||
$product->mImageFiles[] = $image;
|
||||
}
|
||||
|
||||
usleep(200000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getLogger()->notice('Produkt nie zawiera zdjęć...');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMGroup($product, $main_page, $bestseller, $promotion)
|
||||
{
|
||||
if (!empty($main_page))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'MAIN_PAGE');
|
||||
}
|
||||
|
||||
if (!empty($promotion))
|
||||
{
|
||||
$this->addProductToGroupType($product, 'PROMOTION');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMCategoryMulti($product, $category_multi_1, $category_multi_2)
|
||||
{
|
||||
if (!empty($category_multi_1))
|
||||
{
|
||||
$categories = explode("/", $category_multi_1);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
if (!empty($category_multi_2))
|
||||
{
|
||||
$categories = explode("/", $category_multi_2);
|
||||
|
||||
$category = $this->categoryWalk($categories);
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $product
|
||||
*/
|
||||
public function setMCategory($product, $categories, $ids)
|
||||
{
|
||||
$category = $this->categoryWalk(array_values($categories), array_values($ids));
|
||||
|
||||
$this->addProductToCategory($product, $category);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Product $product Product
|
||||
* @param <type> $price_brutto
|
||||
* @param <type> $vat
|
||||
*/
|
||||
public function setMPrice($product, $price_brutto, $vat)
|
||||
{
|
||||
$product->setPriceNettoByBrutto($price_brutto, $vat);
|
||||
}
|
||||
|
||||
public function setMProductOptions($product, $xml_options, $user_id)
|
||||
{
|
||||
$this->mProductOptions = $xml_options;
|
||||
|
||||
$this->mUserId = $user_id;
|
||||
}
|
||||
|
||||
protected function addProductOptions($product, $xml_options, $code, $con = null)
|
||||
{
|
||||
if (!empty($xml_options))
|
||||
{
|
||||
$root = new ProductOptionsValue();
|
||||
|
||||
$root->makeRoot();
|
||||
|
||||
$root->setProduct($product);
|
||||
|
||||
$root->setCulture('pl_PL');
|
||||
|
||||
$root->save($con);
|
||||
|
||||
$attributes = stMigrationSoteshopHelper::xmlOptionsToArray($xml_options);
|
||||
|
||||
$this->addProductOptionsRecursive($product, $attributes, $root, $con);
|
||||
}
|
||||
}
|
||||
|
||||
protected function addProductOptionsRecursive($product, $attributes, $root, $con = null)
|
||||
{
|
||||
if (!is_array($attributes))
|
||||
return;
|
||||
|
||||
foreach ($attributes as $name => $options)
|
||||
{
|
||||
$pof = new ProductOptionsField();
|
||||
|
||||
$pof->setCulture('pl_PL');
|
||||
|
||||
$pof->setName($name);
|
||||
|
||||
$pof->save($con);
|
||||
|
||||
foreach ($options as $name => $params)
|
||||
{
|
||||
$root = $root->reload();
|
||||
|
||||
$pov = new ProductOptionsValue();
|
||||
|
||||
$pov->setCulture('pl_PL');
|
||||
|
||||
$pov->setProduct($product);
|
||||
|
||||
$pov->setProductOptionsField($pof);
|
||||
|
||||
$pov->setValue($name);
|
||||
|
||||
$pov->setPrice($params['price']);
|
||||
|
||||
$pov->setSfAssetId(isset($product->imageNo2Asset[$params['image']]) ? $product->imageNo2Asset[$params['image']] : null);
|
||||
|
||||
$pov->insertAsLastChildOf($root);
|
||||
|
||||
$pov->save($con);
|
||||
|
||||
$root->setRgt($pov->getRgt()+1);
|
||||
|
||||
// $this->addProductOptionsRecursive($product, $params['nested'], $pov);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function addOrderProduct($order)
|
||||
{
|
||||
$data_procesor = new stMigrationDataProcesor();
|
||||
|
||||
$data_retriever = $this->getDataRetriever();
|
||||
|
||||
$model_fillin = $this->getOrderProductFillin();
|
||||
|
||||
$stmt = $data_retriever->prepareStatement('SELECT * FROM order_products WHERE order_id = ?');
|
||||
|
||||
$stmt->setInt(1, $this->mId);
|
||||
|
||||
$stmt->setLimit(0);
|
||||
|
||||
$rs = $stmt->executeQuery();
|
||||
|
||||
$data_procesor->setModelClass('OrderProduct');
|
||||
|
||||
$data_procesor->setModelFillin($model_fillin);
|
||||
|
||||
$data_procesor->setModelParams(array('order' => $order));
|
||||
|
||||
$data_procesor->autoSaveModel(false);
|
||||
|
||||
while ($rs->next())
|
||||
{
|
||||
$data_procesor->process($rs->getRow());
|
||||
}
|
||||
}
|
||||
|
||||
protected function addCategoryPositioning(Category $category, $source_id)
|
||||
{
|
||||
$data_retriever = $this->getDataRetriever();
|
||||
|
||||
$stmt = $data_retriever->prepareStatement('SELECT * FROM category'.$category->getDepth().' WHERE id = ?');
|
||||
|
||||
$stmt->setInt(1, $source_id);
|
||||
|
||||
$stmt->setLimit(1);
|
||||
|
||||
$rs = $stmt->executeQuery();
|
||||
|
||||
if ($rs->next())
|
||||
{
|
||||
if ($title = $rs->getString('title'))
|
||||
{
|
||||
$chp = new CategoryHasPositioning();
|
||||
|
||||
$chp->setCulture('pl_PL');
|
||||
|
||||
$chp->setCategoryId($category->getId());
|
||||
|
||||
$chp->setTitle($title);
|
||||
|
||||
$chp->setKeywords($rs->getString('keywords'));
|
||||
|
||||
$chp->setDescription($rs->getString('description'));
|
||||
|
||||
$chp->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function categoryWalk($path, $ids = array())
|
||||
{
|
||||
$tmp = $this->getRootCategory();
|
||||
|
||||
if (is_null($tmp))
|
||||
{
|
||||
$tmp = new Category();
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
$tmp->setName('Kategorie');
|
||||
|
||||
$tmp->makeRoot();
|
||||
|
||||
$tmp->save();
|
||||
|
||||
$tmp->setScope($tmp->getId());
|
||||
|
||||
$tmp->save();
|
||||
}
|
||||
|
||||
$tmp = $tmp->reload();
|
||||
|
||||
$count = count($path);
|
||||
|
||||
for ($i = 0; $i < $count && !empty($path[$i]); $i++)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryI18nPeer::NAME, $path[$i]);
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, $tmp->getId());
|
||||
|
||||
$c->add(CategoryI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$category = CategoryPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!isset($category[0]))
|
||||
break;
|
||||
|
||||
$tmp = $category[0];
|
||||
}
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
for ($j = $i; $j < $count && !empty($path[$j]); $j++)
|
||||
{
|
||||
|
||||
$category = new Category();
|
||||
|
||||
$category->setCulture('pl_PL');
|
||||
|
||||
$category->setName($path[$j]);
|
||||
|
||||
$dictionary = $this->getDictionary($path[$j]);
|
||||
|
||||
if ($dictionary)
|
||||
{
|
||||
foreach ($dictionary as $culture => $name) {
|
||||
if ($name)
|
||||
{
|
||||
$category->setCulture($culture);
|
||||
$category->setName($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$category->insertAsLastChildOf($tmp);
|
||||
|
||||
$category->setCulture(stLanguage::getOptLanguage());
|
||||
|
||||
$category->save();
|
||||
|
||||
if (isset($ids[$j]))
|
||||
{
|
||||
$this->addCategoryPositioning($category, $ids[$j]);
|
||||
}
|
||||
|
||||
$tmp = $category;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function getRootCategory()
|
||||
{
|
||||
if (is_null($this->rootCategory))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, null, Criteria::ISNULL);
|
||||
|
||||
$this->rootCategory = CategoryPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
return $this->rootCategory;
|
||||
}
|
||||
|
||||
protected function getProductGroupByType($type = 'MAIN_PAGE')
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductGroupPeer::PRODUCT_GROUP, $type);
|
||||
|
||||
return ProductGroupPeer::doSelectOne($c);
|
||||
}
|
||||
|
||||
protected function addProductToGroupType($product, $group_type = 'MAIN_PAGE')
|
||||
{
|
||||
$product_group = $this->getProductGroupByType($group_type);
|
||||
|
||||
$product_group_has_product = new ProductGroupHasProduct();
|
||||
|
||||
$product_group_has_product->setProduct($product);
|
||||
|
||||
$product_group_has_product->setProductGroup($product_group);
|
||||
|
||||
$product->addProductGroupHasProduct($product_group_has_product);
|
||||
}
|
||||
|
||||
protected function addProductToCategory($product, $category)
|
||||
{
|
||||
$product_has_category = new ProductHasCategory();
|
||||
|
||||
$product_has_category->setCategory($category);
|
||||
|
||||
$product->addProductHasCategory($product_has_category);
|
||||
}
|
||||
|
||||
protected function addImageToProduct($product, $image, $default = false, $con = null)
|
||||
{
|
||||
$product_has_asset = new ProductHasSfAsset();
|
||||
|
||||
$product_has_asset->setIsDefault($default);
|
||||
|
||||
$product_has_asset->setProduct($product);
|
||||
|
||||
$filename = basename($image);
|
||||
|
||||
list($image_no) = explode('_', $filename);
|
||||
|
||||
$product_has_asset->createAsset($filename, $image, ProductHasSfAssetPeer::IMAGE_FOLDER);
|
||||
|
||||
$product_has_asset->save($con);
|
||||
|
||||
$product->imageNo2Asset[$image_no] = $product_has_asset->getSfAssetId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationReview.class.php 16984 2012-02-07 12:00:51Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationReview extends stMigrationSoteshopReviewBase
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationsfGuardUser.class.php 13836 2011-06-29 10:17:04Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationsfGuardUser extends stMigrationSoteshopGuardUserModel
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationSoteshopGuardUserModel.class.php 704 2009-09-22 12:52:40Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationSoteshopGuardUserModel extends stMigrationModel
|
||||
{
|
||||
|
||||
protected $billing = null;
|
||||
protected $delivery = null;
|
||||
|
||||
public function postCreate($user)
|
||||
{
|
||||
$user->setIsConfirm(true);
|
||||
|
||||
$user->setIsActive(true);
|
||||
|
||||
$this->billing = null;
|
||||
|
||||
$this->delivery = null;
|
||||
}
|
||||
|
||||
public function postSave($user, $con = null)
|
||||
{
|
||||
if ($this->billing)
|
||||
{
|
||||
$this->billing->setsfGuardUser($user);
|
||||
|
||||
$this->billing->save($con);
|
||||
}
|
||||
|
||||
if ($this->delivery)
|
||||
{
|
||||
$this->delivery->setsfGuardUser($user);
|
||||
|
||||
$this->delivery->save($con);
|
||||
}
|
||||
|
||||
$user->addGroupByName('user');
|
||||
}
|
||||
|
||||
public function setMWholesale($user, $hurt)
|
||||
{
|
||||
if ($hurt)
|
||||
{
|
||||
$user->setWholesale('a');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMCreatedAt($user, $date_add, $date_update)
|
||||
{
|
||||
if (!empty($date_add))
|
||||
{
|
||||
$user->setCreatedAt($date_add);
|
||||
}
|
||||
elseif (!empty($date_update))
|
||||
{
|
||||
$user->setCreatedAt($date_update);
|
||||
}
|
||||
}
|
||||
|
||||
public function validateFillin($user, $data = array())
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardUserPeer::USERNAME, $this->decrypt($data['crypt_login']));
|
||||
|
||||
return!sfGuardUserPeer::doCount($c);
|
||||
}
|
||||
|
||||
public function setMUsername($user, $username)
|
||||
{
|
||||
$user->setUsername($this->decrypt($username));
|
||||
}
|
||||
|
||||
public function setMPassword($user, $password)
|
||||
{
|
||||
$user->setPasswordHash($password);
|
||||
|
||||
$user->setSalt('');
|
||||
|
||||
$user->setAlgorithm('stMigrationSoteshopHelper::algorithm');
|
||||
}
|
||||
|
||||
public function setMUserData($user, $billing, $delivery = array())
|
||||
{
|
||||
if (!sfToolkit::isArrayValuesEmpty($billing))
|
||||
{
|
||||
$this->billing = new UserData();
|
||||
|
||||
$this->billing->setIsBilling(true);
|
||||
|
||||
$this->billing->setIsDefault(true);
|
||||
|
||||
$this->billing->setFullName(stMigrationSoteshopHelper::getFullName($billing['crypt_name'], $billing['crypt_surname']));
|
||||
|
||||
$this->billing->setAddress(stMigrationSoteshopHelper::getAddress($billing['crypt_street'], $billing['crypt_street_n1'], $billing['crypt_street_n2']));
|
||||
|
||||
$this->billing->setCode($this->decrypt($billing['crypt_postcode']));
|
||||
|
||||
$this->billing->setTown($this->decrypt($billing['crypt_city']));
|
||||
|
||||
$country = $this->retrieveCountryByName($this->decrypt($billing['crypt_country']));
|
||||
|
||||
$this->billing->setCountries($country);
|
||||
|
||||
$this->billing->setPhone($this->decrypt($billing['crypt_phone']));
|
||||
|
||||
$this->billing->setCompany($this->decrypt($billing['crypt_firm']));
|
||||
|
||||
$this->billing->setVatNumber($this->decrypt($billing['crypt_nip']));
|
||||
}
|
||||
|
||||
if (sfToolkit::isArrayValuesEmpty($delivery) && $this->billing)
|
||||
{
|
||||
$this->delivery = $this->billing->copy();
|
||||
|
||||
$this->delivery->setIsBilling(false);
|
||||
}
|
||||
elseif (!sfToolkit::isArrayValuesEmpty($delivery))
|
||||
{
|
||||
$this->delivery = new UserData();
|
||||
|
||||
$this->delivery->setIsDefault(true);
|
||||
|
||||
$this->delivery->setFullName(stMigrationSoteshopHelper::getFullName($delivery['crypt_cor_name'], $delivery['crypt_cor_surname']));
|
||||
|
||||
$this->delivery->setAddress(stMigrationSoteshopHelper::getAddress($delivery['crypt_cor_street'], $delivery['crypt_cor_street_n1'], $delivery['crypt_cor_street_n2']));
|
||||
|
||||
$this->delivery->setCode($this->decrypt($delivery['crypt_cor_postcode']));
|
||||
|
||||
$this->delivery->setTown($this->decrypt($delivery['crypt_cor_city']));
|
||||
|
||||
$country = $this->retrieveCountryByName($this->decrypt($delivery['crypt_cor_country']));
|
||||
|
||||
$this->delivery->setCountries($country);
|
||||
|
||||
$this->delivery->setPhone($this->decrypt($delivery['crypt_cor_phone']));
|
||||
|
||||
$this->delivery->setCompany($this->decrypt($delivery['crypt_cor_firm']));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function retrieveCountryByName($name)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CountriesI18nPeer::NAME, $name);
|
||||
|
||||
$c->add(CountriesI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$countries = CountriesPeer::doSelectWithI18n($c);
|
||||
|
||||
return isset($countries[0]) ? $countries[0] : CountriesPeer::retrieveByPk(36);
|
||||
}
|
||||
|
||||
protected function decrypt($data)
|
||||
{
|
||||
return stMigrationSoteshopHelper::decrypt($data);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,438 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationOrder.class.php 3823 2010-03-09 10:33:42Z pawel $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationSoteshopOrderBase extends stMigrationModel
|
||||
{
|
||||
protected $payment = null;
|
||||
|
||||
public function postCreate($order)
|
||||
{
|
||||
$this->payment = null;
|
||||
}
|
||||
|
||||
public function setMId($order, $o_id)
|
||||
{
|
||||
$this->mId = $o_id;
|
||||
|
||||
$order->setNumber($o_id);
|
||||
}
|
||||
|
||||
public function setMStatus($order, $o_confirm, $o_cancel = false)
|
||||
{
|
||||
if ($o_confirm)
|
||||
{
|
||||
$order_status = OrderStatusPeer::retrieveSystemStatusByType('ST_COMPLETE');
|
||||
}
|
||||
elseif ($o_cancel)
|
||||
{
|
||||
$order_status = OrderStatusPeer::retrieveSystemStatusByType('ST_CANCELED');
|
||||
}
|
||||
else
|
||||
{
|
||||
$order_status = OrderStatusPeer::retrieveSystemStatusByType('ST_PENDING');
|
||||
}
|
||||
|
||||
$order->setOrderStatus($order_status);
|
||||
}
|
||||
|
||||
public function setMCreatedAt($order, $o_date_add, $o_time_add)
|
||||
{
|
||||
$time = $o_date_add . ' ' . $o_time_add;
|
||||
|
||||
if (strtotime($time) != -1)
|
||||
{
|
||||
$order->setCreatedAt($time);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMUpdatedAt($order, $time)
|
||||
{
|
||||
if (strtotime($time) != -1)
|
||||
{
|
||||
$order->setUpdatedAt($time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Order $order Zamówienie
|
||||
*/
|
||||
public function setMDelivery($order, $d_name, $d_price)
|
||||
{
|
||||
$order_delivery = new OrderDelivery();
|
||||
|
||||
$order_delivery->setName($d_name);
|
||||
|
||||
$order_delivery->setCost(stCurrency::extractNettoFromBrutto($d_price, 22));
|
||||
|
||||
$order_delivery->setOptTax(22);
|
||||
|
||||
$order->setOrderDelivery($order_delivery);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Order $order Zamówienie
|
||||
*/
|
||||
public function preSave($order)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CurrencyPeer::SHORTCUT, 'PLN');
|
||||
|
||||
$currency = CurrencyPeer::doSelectOne($c);
|
||||
|
||||
$order->getOrderCurrency()->setShortcut($currency->getShortcut());
|
||||
|
||||
$order->getOrderCurrency()->setBackSymbol($currency->getBackSymbol());
|
||||
|
||||
$order->getOrderCurrency()->setFrontSymbol($currency->getFrontSymbol());
|
||||
|
||||
$order->getOrderCurrency()->setExchange($currency->getExchange());
|
||||
|
||||
$this->addOrderProduct($order);
|
||||
|
||||
if (null !== $this->payment)
|
||||
{
|
||||
$payment = stPayment::newPaymentInstance($this->payment['id'], $order->getTotalAmountWithDelivery(true, true), array('user_id' => $order->getsfGuardUserId(), 'is_paid' => $this->payment['is_paid']));
|
||||
|
||||
if ($this->payment['is_paid'])
|
||||
{
|
||||
$payment->setPayedAt($order->getCreatedAt());
|
||||
}
|
||||
|
||||
$order->addOrderPayment($payment);
|
||||
|
||||
$order->setOptIsPayed($this->payment['is_paid']);
|
||||
}
|
||||
}
|
||||
|
||||
public function postSave($order)
|
||||
{
|
||||
}
|
||||
|
||||
public function setMUser($order, $crypt_login, $crypt_email)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$username = $this->decrypt($crypt_login);
|
||||
|
||||
$email = $this->decrypt($crypt_email);
|
||||
|
||||
$username = str_replace("'", "", trim($username));
|
||||
|
||||
$email = str_replace("'", "", trim($email));
|
||||
|
||||
$criterion = $c->getNewCriterion(sfGuardUserPeer::USERNAME, $username);
|
||||
|
||||
$criterion->addOr($c->getNewCriterion(sfGuardUserPeer::USERNAME, $email));
|
||||
|
||||
$c->add($criterion);
|
||||
|
||||
$user = sfGuardUserPeer::doSelectOne($c);
|
||||
|
||||
if ($user && $user->getUsername())
|
||||
{
|
||||
$order->setsfGuardUser($user);
|
||||
}
|
||||
elseif (!empty($email))
|
||||
{
|
||||
$user = $this->addAnonymousUser($email);
|
||||
|
||||
$user->setCreatedAt($order->getCreatedAt());
|
||||
|
||||
$user->save();
|
||||
|
||||
$order->setsfGuardUser($user);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMPayment($order, $payment_id, $confirm, $confirm_online)
|
||||
{
|
||||
if ($payment_id)
|
||||
{
|
||||
$this->payment = array('id' => $this->getPaymentTypeIdByPaymentId($payment_id), 'is_paid' => $confirm || $confirm_online);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMUserData($order, $billing, $delivery)
|
||||
{
|
||||
if (!sfToolkit::isArrayValuesEmpty($billing))
|
||||
{
|
||||
$order->getOrderUserDataBilling()->setFullName(stMigrationSoteshopHelper::getFullName($billing['crypt_name'], $billing['crypt_surname']));
|
||||
|
||||
$order->getOrderUserDataBilling()->setAddress(stMigrationSoteshopHelper::getAddress($billing['crypt_street'], $billing['crypt_street_n1'], $billing['crypt_street_n2']));
|
||||
|
||||
$order->getOrderUserDataBilling()->setCode($this->decrypt($billing['crypt_postcode']));
|
||||
|
||||
$order->getOrderUserDataBilling()->setTown($this->decrypt($billing['crypt_city']));
|
||||
|
||||
$country = $this->retrieveCountryByName($this->decrypt($billing['crypt_country']));
|
||||
|
||||
$order->getOrderUserDataBilling()->setCountry($country->getName());
|
||||
|
||||
$order->getOrderUserDataBilling()->setPhone($this->decrypt($billing['crypt_phone']));
|
||||
|
||||
$order->getOrderUserDataBilling()->setCompany($this->decrypt($billing['crypt_firm']));
|
||||
|
||||
$order->getOrderUserDataBilling()->setVatNumber($this->decrypt($billing['crypt_nip']));
|
||||
}
|
||||
|
||||
if (sfToolkit::isArrayValuesEmpty($delivery))
|
||||
{
|
||||
$delivery['crypt_cor_name'] = $billing['crypt_name'];
|
||||
$delivery['crypt_cor_surname'] = $billing['crypt_surname'];
|
||||
$delivery['crypt_cor_street'] = $billing['crypt_street'];
|
||||
$delivery['crypt_cor_street_n1'] = $billing['crypt_street_n1'];
|
||||
$delivery['crypt_cor_street_n2'] = $billing['crypt_street_n2'];
|
||||
$delivery['crypt_cor_postcode'] = $billing['crypt_postcode'];
|
||||
$delivery['crypt_cor_city'] = $billing['crypt_city'];
|
||||
$delivery['crypt_cor_country'] = $billing['crypt_country'];
|
||||
$delivery['crypt_cor_phone'] = $billing['crypt_phone'];
|
||||
$delivery['crypt_cor_firm'] = $billing['crypt_firm'];
|
||||
}
|
||||
|
||||
if (!sfToolkit::isArrayValuesEmpty($delivery))
|
||||
{
|
||||
$order->getOrderUserDataDelivery()->setFullName(stMigrationSoteshopHelper::getFullName($delivery['crypt_cor_name'], $delivery['crypt_cor_surname']));
|
||||
|
||||
$order->getOrderUserDataDelivery()->setAddress(stMigrationSoteshopHelper::getAddress($delivery['crypt_cor_street'], $delivery['crypt_cor_street_n1'], $delivery['crypt_cor_street_n2']));
|
||||
|
||||
$order->getOrderUserDataDelivery()->setCode($this->decrypt($delivery['crypt_cor_postcode']));
|
||||
|
||||
$order->getOrderUserDataDelivery()->setTown($this->decrypt($delivery['crypt_cor_city']));
|
||||
|
||||
$country = $this->retrieveCountryByName($this->decrypt($delivery['crypt_cor_country']));
|
||||
|
||||
$order->getOrderUserDataDelivery()->setCountry($country->getName());
|
||||
|
||||
$order->getOrderUserDataDelivery()->setPhone($this->decrypt($delivery['crypt_cor_phone']));
|
||||
|
||||
$order->getOrderUserDataDelivery()->setCompany($this->decrypt($delivery['crypt_cor_firm']));
|
||||
}
|
||||
}
|
||||
|
||||
protected function getOrderProductFillin()
|
||||
{
|
||||
return array('m_code' => array('params' => 'user_id_main'), 'name' => array('params' => 'name'), 'quantity' => array('params' => 'num'), 'm_price' => array('params' => array('price_brutto', 'vat')), 'm_product' => array('params' => array('user_id_main')));
|
||||
}
|
||||
|
||||
protected function retrieveCountryByName($name)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CountriesI18nPeer::NAME, $name);
|
||||
|
||||
$c->add(CountriesI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$countries = CountriesPeer::doSelectWithI18n($c);
|
||||
|
||||
if (!$countries)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CountriesPeer::ISO_A2, $name);
|
||||
|
||||
$c->add(CountriesI18nPeer::CULTURE, 'pl_PL');
|
||||
|
||||
$countries = CountriesPeer::doSelectWithI18n($c);
|
||||
}
|
||||
|
||||
return isset($countries[0]) ? $countries[0] : CountriesPeer::doSelectDefault(new Criteria());
|
||||
}
|
||||
|
||||
protected function decrypt($data)
|
||||
{
|
||||
return stMigrationSoteshopHelper::decrypt($data);
|
||||
}
|
||||
|
||||
protected function addOrderProduct($order)
|
||||
{
|
||||
$data_procesor = new stMigrationDataProcesor();
|
||||
|
||||
$data_retriever = $this->getDataRetriever();
|
||||
|
||||
$model_fillin = $this->getOrderProductFillin();
|
||||
|
||||
$stmt = $data_retriever->prepareStatement('SELECT * FROM order_products WHERE order_id = ?');
|
||||
|
||||
$stmt->setInt(1, $this->mId);
|
||||
|
||||
$stmt->setLimit(0);
|
||||
|
||||
$rs = $stmt->executeQuery();
|
||||
|
||||
$data_procesor->setModelClass('OrderProduct');
|
||||
|
||||
$data_procesor->setModelFillin($model_fillin);
|
||||
|
||||
$data_procesor->setModelParams(array('order' => $order));
|
||||
|
||||
$data_procesor->autoSaveModel(false);
|
||||
|
||||
while ($rs->next())
|
||||
{
|
||||
$data_procesor->process($rs->getRow());
|
||||
}
|
||||
}
|
||||
|
||||
public static function addAnonymousUser($username)
|
||||
{
|
||||
$user = new sfGuardUser();
|
||||
$user->setUsername($username);
|
||||
$user->setPassword('anonymous');
|
||||
$user->save();
|
||||
|
||||
$user->addGroupByName('user');
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public static function preProcess(stMigrationDataRetriever $data_retriever)
|
||||
{
|
||||
$connection = Propel::getConnection();
|
||||
|
||||
$connection->executeQuery('ALTER TABLE `st_order` AUTO_INCREMENT=1');
|
||||
}
|
||||
|
||||
public static function postProcess(stMigrationDataRetriever $data_retriever)
|
||||
{
|
||||
$connection = Propel::getConnection();
|
||||
|
||||
$rs = $connection->executeQuery('SELECT max(o.NUMBER + 0) as number FROM `st_order` o', ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$number = $rs->next() ? $rs->getInt('number') : 0;
|
||||
|
||||
$rs = $connection->executeQuery('SELECT max(o.ID) as id FROM `st_order` o', ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$id = $rs->next() ? $rs->getInt('id') : 0;
|
||||
|
||||
if ($number > $id)
|
||||
{
|
||||
$stm = $connection->prepareStatement('ALTER TABLE `st_order` AUTO_INCREMENT=?');
|
||||
|
||||
$stm->setInt(1, $number + 1);
|
||||
|
||||
$stm->executeQuery();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getPaymentTypeIdByPaymentId($id)
|
||||
{
|
||||
$payment_names = array(
|
||||
"1"=>"Płatność gotówką",
|
||||
"2"=>"eCard",
|
||||
"3"=>"Polcard",
|
||||
"10"=>"Płatność gotówką",
|
||||
"11"=>"Płatność przelewem",
|
||||
"12"=>"Przelewy24",
|
||||
"20"=>"Płatności.pl",
|
||||
"21"=>"Dotpay",
|
||||
"22"=>"Żagiel - eRaty",
|
||||
"101"=>"PayPal",
|
||||
"110"=>"Płatność Kartą",
|
||||
);
|
||||
|
||||
$name = isset($payment_names[$id]) ? $payment_names[$id] : 'niestandardowa';
|
||||
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(PaymentTypePeer::OPT_NAME, $name);
|
||||
|
||||
$payment_type = PaymentTypePeer::doSelectOne($c);
|
||||
|
||||
if (null === $payment_type)
|
||||
{
|
||||
$payment_type = new PaymentType();
|
||||
|
||||
$payment_type->setCulture('pl_PL');
|
||||
|
||||
$payment_type->setName($name);
|
||||
|
||||
$payment_type->setModuleName('stStandardPayment');
|
||||
|
||||
$payment_type->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
$payment_type->setCulture('pl_PL');
|
||||
}
|
||||
|
||||
return $payment_type->getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class stMigrationOrderProduct extends stMigrationModel
|
||||
{
|
||||
|
||||
/**
|
||||
* Przypisuje produkt do aktualnego zamówienia
|
||||
*
|
||||
* @param OrderProduct $order_product Produkt w zamówieniu
|
||||
*/
|
||||
public function postCreate($order_product)
|
||||
{
|
||||
$order = $this->getMigrationParam('order');
|
||||
|
||||
$order->addOrderProduct($order_product);
|
||||
}
|
||||
|
||||
public function setMCode($order_product, $code)
|
||||
{
|
||||
$order_product->setCode(stMigrationSoteshopHelper::fixString($code));
|
||||
}
|
||||
|
||||
public function setMProduct($order_product, $code)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductPeer::CODE, stMigrationSoteshopHelper::fixString($code));
|
||||
|
||||
$product = ProductPeer::doSelectOne($c);
|
||||
|
||||
$order_product->setProduct($product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia cenę produktu
|
||||
*
|
||||
* @param OrderProduct $order_product Produkt w zamówieniu
|
||||
* @param float $price_brutto Cena brutto
|
||||
* @param float $vat Vat
|
||||
*/
|
||||
public function setMPrice($order_product, $price_brutto, $vat)
|
||||
{
|
||||
$price = stMigrationSoteshopHelper::calculateNettoPrice($price_brutto, $vat);
|
||||
|
||||
$order_product->setPrice($price);
|
||||
|
||||
$order_product->setPriceBrutto($price_brutto);
|
||||
|
||||
$order_product->setVat($vat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
class stMigrationSoteshopReviewBase extends stMigrationModel
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param Review $review
|
||||
*/
|
||||
public function postCreate($review)
|
||||
{
|
||||
$review->setActive(true);
|
||||
|
||||
$review->setAdminActive(true);
|
||||
|
||||
$review->setAgreement(true);
|
||||
|
||||
$review->setLanguage('pl_PL');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Review $review
|
||||
* @param string $user_id Id produktu nadane przez administratora
|
||||
*/
|
||||
public function setMProductId($review, $user_id)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ProductPeer::CODE, stMigrationSoteshopHelper::fixString($user_id));
|
||||
|
||||
$product = ProductPeer::doSelectOne($c);
|
||||
|
||||
$review->setProductId($product ? $product->getId() : null);
|
||||
|
||||
unset($product);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stMigrationSoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stMigrationSoteshopPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stMigrationSoteshopHelper.class.php 13946 2011-07-05 13:22:43Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za obsługę procesu migracji
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
* @package stMigrationSoteshopPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stMigrationSoteshopHelper
|
||||
{
|
||||
const SALT = 'f37e02d876032f4335ceb2c97a4b831c';
|
||||
|
||||
protected static $rootCategory = null;
|
||||
|
||||
public static function getCultureByLangId($lang_id)
|
||||
{
|
||||
$culture = array(0 => 'pl_PL', 1 => 'en_US', 2 => 'de', 3 => 'cs', 4 => 'ru');
|
||||
|
||||
return isset($culture[$lang_id]) ? $culture[$lang_id] : 'pl_PL';
|
||||
}
|
||||
|
||||
public static function xmlOptionsToArray($xml_options)
|
||||
{
|
||||
$xml_options = str_replace("\r\n", "\n", $xml_options);
|
||||
|
||||
$attributes = explode("\n\n", $xml_options);
|
||||
|
||||
return self::xmlOptionToArrayHelper($attributes, 0);
|
||||
}
|
||||
|
||||
public static function xmlOptionToArrayHelper($attributes)
|
||||
{
|
||||
$arr = array();
|
||||
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
$tmp = explode("\n", $attribute);
|
||||
|
||||
$name = trim($tmp[0]);
|
||||
|
||||
unset($tmp[0]);
|
||||
|
||||
if ($name == 'multi')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($tmp as $i => $option)
|
||||
{
|
||||
@list($opt_name, $opt_price, $opt_image) = explode(',', $option);
|
||||
|
||||
$opt_name = trim($opt_name);
|
||||
|
||||
$arr[$name][$opt_name]['price'] = trim($opt_price);
|
||||
|
||||
$arr[$name][$opt_name]['image'] = trim($opt_image);
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public static function getAddress($crypt_street, $crypt_house, $crypt_flat)
|
||||
{
|
||||
$address = self::decrypt($crypt_street);
|
||||
|
||||
if ($crypt_house || $crypt_flat)
|
||||
{
|
||||
$address .= ' ';
|
||||
}
|
||||
|
||||
if ($crypt_house)
|
||||
{
|
||||
$address .= self::decrypt($crypt_house);
|
||||
}
|
||||
|
||||
if ($crypt_house && $crypt_flat)
|
||||
{
|
||||
$address .= '/';
|
||||
}
|
||||
|
||||
if ($crypt_flat)
|
||||
{
|
||||
$address .= self::decrypt($crypt_flat);
|
||||
}
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
public static function getFullName($crypt_name, $crypt_surname)
|
||||
{
|
||||
return self::decrypt($crypt_name) . ' ' . self::decrypt($crypt_surname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Odkodowuje dane z wersji 3.x, 4.0
|
||||
*
|
||||
* @param string $data Dane do odkodowania
|
||||
*
|
||||
* @return string Odkodowane dane
|
||||
*/
|
||||
public static function decrypt($data)
|
||||
{
|
||||
$pwd = md5(self::SALT);
|
||||
|
||||
$data = urldecode($data);
|
||||
|
||||
$key[] = "";
|
||||
|
||||
$box[] = "";
|
||||
|
||||
$temp_swap = "";
|
||||
|
||||
$pwd_length = 0;
|
||||
|
||||
$pwd_length = strlen($pwd);
|
||||
|
||||
for ($i = 0; $i < 255; $i++)
|
||||
{
|
||||
|
||||
$key[$i] = ord(substr($pwd, ($i % $pwd_length) + 1, 1));
|
||||
$box[$i] = $i;
|
||||
}
|
||||
|
||||
$x = 0;
|
||||
|
||||
for ($i = 0; $i < 255; $i++)
|
||||
{
|
||||
$x = ($x + $box[$i] + $key[$i]) % 256;
|
||||
|
||||
$temp_swap = $box[$i];
|
||||
|
||||
@$box[$i] = $box[$x];
|
||||
|
||||
$box[$x] = $temp_swap;
|
||||
}
|
||||
|
||||
$temp = "";
|
||||
|
||||
$k = "";
|
||||
|
||||
$cipherby = "";
|
||||
|
||||
$cipher = "";
|
||||
|
||||
$a = 0;
|
||||
|
||||
$j = 0;
|
||||
|
||||
for ($i = 0; $i < strlen($data); $i++)
|
||||
{
|
||||
$a = ($a + 1) % 256;
|
||||
|
||||
$j = ($j + $box[$a]) % 256;
|
||||
|
||||
$temp = $box[$a];
|
||||
|
||||
@$box[$a] = $box[$j];
|
||||
|
||||
$box[$j] = $temp;
|
||||
|
||||
@$k = $box[(($box[$a] + $box[$j]) % 256)];
|
||||
|
||||
$cipherby = ord(substr($data, $i, 1)) ^ $k;
|
||||
|
||||
$cipher .= chr($cipherby);
|
||||
}
|
||||
|
||||
return iconv('ISO-8859-2', 'UTF-8', $cipher);
|
||||
}
|
||||
|
||||
public static function algorithm($password)
|
||||
{
|
||||
return md5($password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Oblicza kwotę netto na podstawie kwoty brutto i vatu
|
||||
*
|
||||
* @param float $price_with_vat Kwota brutto
|
||||
* @param float $vat Vat
|
||||
*
|
||||
* @return float Kwota netto
|
||||
*/
|
||||
public static function calculateNettoPrice($price_with_vat, $vat)
|
||||
{
|
||||
return $price_with_vat / (1 + $vat / 100);
|
||||
}
|
||||
|
||||
public static function fixString($code)
|
||||
{
|
||||
$code = str_replace(" ", "-", $code);
|
||||
|
||||
return preg_replace("/[^a-zA-Z0-9_-]/", "_", $code);
|
||||
}
|
||||
|
||||
public static function getRootCategory()
|
||||
{
|
||||
if (null === self::$rootCategory)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryPeer::PARENT_ID, null, Criteria::ISNULL);
|
||||
|
||||
self::$rootCategory = CategoryPeer::doSelectOne($c);
|
||||
|
||||
if (null === self::$rootCategory)
|
||||
{
|
||||
$tmp = new Category();
|
||||
|
||||
$tmp->setCulture('pl_PL');
|
||||
|
||||
$tmp->setName('Kategorie');
|
||||
|
||||
$tmp->makeRoot();
|
||||
|
||||
$tmp->save();
|
||||
|
||||
$tmp->setScope($tmp->getId());
|
||||
|
||||
$tmp->save();
|
||||
|
||||
self::$rootCategory = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return self::$rootCategory;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user