first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,285 @@
<?php
/**
* SOTESHOP/stCeneoPlugin
*
* Ten plik należy do aplikacji stCeneoPlugin 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 stCeneoPlugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: actions.class.php 16435 2011-12-12 08:34:51Z michal $
* @author Michal Prochowski <michal.prochowski@sote.pl>
*/
/**
* Klasa stCeneoBackendActions
*
* @package stCeneoPlugin
* @subpackage actions
*/
class stCeneoBackendActions extends autostCeneoBackendActions
{
/**
* Walidacja akcji Config
*/
public function validateConfig()
{
$error = false;
$request = $this->getRequest();
$data = $request->getParameter('config');
if (isset($data['trusted_opinion_on']) && $data['trusted_opinion_on'] == 1)
{
if (isset($data['trusted_opinion_id']) && empty($data['trusted_opinion_id']))
{
$request->setError('config{trusted_opinion_id}', 'Proszę uzupełnić pole.');
$error = true;
}
}
if ($error == true)
{
return false;
}
return true;
}
/**
* Przeciążenie aktualizacji config'a
*/
protected function updateConfigFromRequest()
{
$config = $this->getRequestParameter('config');
foreach (stCeneo::getAvailabilities() as $availability)
{
$this->config->set('availability_'.$availability->getId(), $config['availability_'.$availability->getId()]);
}
if (is_dir(sfConfig::get('sf_plugins_dir')."/appAdsTrackerPlugin")) {
if ($config['ads_tracker']==1) {
appAdsTracker::checkCompare("ceneo",1);
} else {
appAdsTracker::checkCompare("ceneo",0);
}
}
parent::updateConfigFromRequest();
$this->dispatcher->notify(new sfEvent($this, 'stCeneoBackendActions.updateConfigFromRequest'), array('config' => $this->config));
}
public function executeProductEnable()
{
$config = stConfig::getInstance(sfContext::getInstance(), 'stCeneoBackend');
$ids = $this->getRequestParameter('ceneo[selected]', array());
foreach ($ids as $id) {
$c = new Criteria();
$c->add(CeneoPeer::ID, $id);
$Ceneo = CeneoPeer::doSelectOne($c);
if (null === $Ceneo) {
$Ceneo = new Ceneo();
$Ceneo->setProductId($id);
}
if ($config->get('buy_now')==1) {
$Ceneo->setIsBasket(true);
}
$Ceneo->setActive(true);
$Ceneo->save();
}
return $this->redirect('stCeneoBackend/list?page=' . $this->getRequestParameter('page', 1));
}
public function executeProductDisable()
{
$ids = $this->getRequestParameter('ceneo[selected]', array());
$con = Propel::getConnection();
$sel = new Criteria();
$sel->add(CeneoPeer::ID, array_values($ids), Criteria::IN);
$up = new Criteria();
$up->add(CeneoPeer::ACTIVE, false);
BasePeer::doUpdate($sel, $up, $con);
return $this->redirect('stCeneoBackend/list?page=' . $this->getRequestParameter('page', 1));
}
protected function addFiltersCriteria($c)
{
if (isset($this->filters['code_is_empty'])) {
$criterion = $c->getNewCriterion(ProductPeer::CODE, '');
$criterion->addOr($c->getNewCriterion(ProductPeer::CODE, null, Criteria::ISNULL));
$c->add($criterion);
} else if (isset($this->filters['code']) && $this->filters['code'] !== '') {
if (method_exists($this, 'filterCriteriaByProductCode')) {
$filter_anyway = !$this->filterCriteriaByProductCode($c, $this->filters['code']);
} else {
$filter_anyway = true;
}
if ($filter_anyway) {
$c->add(ProductPeer::CODE, '%' . $this->filters['code'] . '%', Criteria::LIKE);
}
}
if (isset($this->filters['product_is_empty'])) {
$criterion = $c->getNewCriterion(ProductPeer::OPT_NAME, '');
$criterion->addOr($c->getNewCriterion(ProductPeer::OPT_NAME, null, Criteria::ISNULL));
$c->add($criterion);
} else if (isset($this->filters['product']) && $this->filters['product'] !== '') {
if (method_exists($this, 'filterCriteriaByProductOptName')) {
$filter_anyway = !$this->filterCriteriaByProductOptName($c, $this->filters['product']);
} else {
$filter_anyway = true;
}
if ($filter_anyway) {
$c->add(ProductPeer::OPT_NAME, '%' . $this->filters['product'] . '%', Criteria::LIKE);
}
}
if (isset($this->filters['active_is_empty'])) {
$criterion = $c->getNewCriterion(CeneoPeer::ACTIVE, '');
$criterion->addOr($c->getNewCriterion(CeneoPeer::ACTIVE, null, Criteria::ISNULL));
$c->add($criterion);
} else if (isset($this->filters['active']) && $this->filters['active'] !== '') {
if ($this->filters['active'] == null || $this->filters['active'] == 0) {
$criterion = $c->getNewCriterion(CeneoPeer::ACTIVE, '');
$criterion->addOr($c->getNewCriterion(CeneoPeer::ACTIVE, null, Criteria::ISNULL));
$c->add($criterion);
}
if ($this->filters['active'] == 1) {
$c->add(CeneoPeer::ACTIVE, $this->filters['active']);
}
}
if ($this->filters) {
$c->add(CeneoPeer::PRODUCT_ID, 0, Criteria::NOT_EQUAL);
}
if (isset($this->filters['is_basket']) && $this->filters['is_basket'] !== '') {
if($this->filters['is_basket']){
$c->add(CeneoPeer::IS_BASKET, $this->filters['is_basket']);
}
else
{
$criterion = $c->getNewCriterion(CeneoPeer::IS_BASKET, 0);
$criterion->addOr($c->getNewCriterion(CeneoPeer::IS_BASKET, null, Criteria::ISNULL));
$c->add($criterion);
}
}
$this->getDispatcher()->notify(new sfEvent($this, 'autoStCeneoBackendActions.addFiltersCriteria', array('criteria' => $c)));
}
public function executeAddAll()
{
$config = stConfig::getInstance(sfContext::getInstance(), 'stCeneoBackend');
$con = Propel::getConnection();
$query = sprintf(
'INSERT INTO %s(%s, %s) (SELECT %s, 1 FROM %s LEFT JOIN %s AS assigned ON (%s = %s) WHERE %s IS NULL)',
CeneoPeer::TABLE_NAME,
CeneoPeer::PRODUCT_ID,
CeneoPeer::ACTIVE,
ProductPeer::ID,
ProductPeer::TABLE_NAME,
CeneoPeer::TABLE_NAME,
CeneoPeer::alias('assigned', CeneoPeer::PRODUCT_ID),
ProductPeer::ID,
CeneoPeer::alias('assigned', CeneoPeer::PRODUCT_ID)
);
$con->executeQuery($query);
$sel = new Criteria();
$sel->add(CeneoPeer::ACTIVE, false);
$up = new Criteria();
$up->add(CeneoPeer::ACTIVE, true);
BasePeer::doUpdate($sel, $up, $con);
if ($config->get('buy_now') == 1) {
$sel = new Criteria();
$sel->add(CeneoPeer::ACTIVE, true);
$up = new Criteria();
$up->add(CeneoPeer::IS_BASKET, 1);
BasePeer::doUpdate($sel, $up, $con);
}
return $this->redirect('stCeneoBackend/list?page=' . $this->getRequestParameter('page', 1));
}
public function executeDeleteAll()
{
$con = Propel::getConnection();
$sel = new Criteria();
$sel->add(CeneoPeer::ACTIVE, true);
$up = new Criteria();
$up->add(CeneoPeer::ACTIVE, false);
BasePeer::doUpdate($sel, $up, $con);
return $this->redirect('stCeneoBackend/list?page=' . $this->getRequestParameter('page', 1));
}
protected function getCeneoOrCreate($id = 'id')
{
$ceneo = CeneoPeer::retrieveByProduct($this->related_object);
if (null === $ceneo) {
if ($this->hasRequestParameter('id'))
{
return $this->redirect('@stCeneoPlugin?action=create&product_id=' . $this->related_object->getId().'&view=default');
}
else
{
$ceneo = new Ceneo();
$ceneo->setProduct($this->related_object);
}
}
return $ceneo;
}
public function executeGenerateCustom()
{
parent::executeGenerateCustom();
$i18n = $this->getContext()->getI18n();
$this->getBreadcrumbsBuilder()->getDefaultBreadcrumbs()->add($i18n->__('Generowanie pliku'));
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* SOTESHOP/stCeneoPlugin
*
* Ten plik należy do aplikacji stCeneoPlugin 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 stCeneoPlugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: components.class.php 10 2009-08-24 09:32:18Z michal $
* @author Michal Prochowski <michal.prochowski@sote.pl>
*/
/**
* Klasa stCeneoBackendComponents
*
* @package stCeneoPlugin
* @subpackage actions
*/
class stCeneoBackendComponents extends autostCeneoBackendComponents
{
/**
* Generowanie pliku xml
*/
public function executeGenerateXml()
{
$this->generate = false;
if ($this->getRequest()->hasParameter('generate')) $this->generate = true;
$stCeneo = new stCeneo();
$this->steps = $stCeneo->getStepsCount();
}
}

View File

@@ -0,0 +1,114 @@
generator:
class: stAdminGenerator
param:
model_class: Ceneo
theme: simple
head:
package: stCeneoPlugin
documentation:
pl: https://www.sote.pl/docs/ceneo
en: https://www.soteshop.com/docs/ceneo
list:
title: Lista produktów
description: Zarządzanie porównywarką cen Ceneo
max_per_page: 20
display: [_code, _product, is_basket, active]
peer_method: doSelectRightJoinProduct
peer_count_method: doCountRightJoinProduct
actions:
_deletes: {name: Wypisz wszystkie, action: deleteAll, icon: delete}
_add: {name: Przypisz wszystkie, action: addAll}
_generate: {name: Generuj plik xml z przypisanych, action: "@stCeneoPlugin?action=generateCustom&generate=1", icon: export}
object_actions: -
select_actions:
display:
"Ustaw przypisane:": [product_enabled, product_disabled]
actions:
product_enabled: {name: Tak, confirm: "Ustaw przypisane: Tak", action: productEnable, i18n: stCeneoBackend}
product_disabled: {name: Nie, confirm: "Ustaw przypisane: Nie", action: productDisable, i18n: stCeneoBackend}
filters:
code: {filter_field: product.code}
product: {filter_field: product.opt_name}
fields:
code: {name: Kod, sort_field: product.code, params: size=50}
product: {name: Nazwa, sort_field: product.opt_name, params: size=50}
is_basket: {name: Kup Teraz}
active: {name: Przypisany}
menu:
display: [list, generate, config]
fields:
list: {name: Lista produktów, action: @stCeneoPluginDefault}
generate: {name: Generowanie pliku, action: stCeneoBackend/generateCustom}
config: {name: Konfiguracja, action: stCeneoBackend/config}
object_actions:
_edit: {action: @stCeneoPlugin?action=edit&id=%%id%%&product_id=%%product_id%%&view=default}
create:
title: Edycja
edit:
menu: {use: list.menu}
display: [active, is_basket]
fields:
active: {name: Przypisany}
is_basket: {name: Kup Teraz, help: "Po zaznaczeniu, produkt bedzie miał opcję Kup Teraz na Ceneo"}
actions:
_list: {name: Lista}
_save: {name: Zapisz}
forward_parameters: [product_id, view]
build_options:
related_id: forward_parameters.product_id
related_class: Product
generate_model_class: Ceneo
custom_actions:
custom: [generate]
generate_custom:
menu: {use: list.menu}
title: Generowanie pliku
description: Zarządzanie porównywarką cen Ceneo
config:
title: Konfiguracja
description: Zarządzanie porównywarką cen Ceneo
display:
"Zaufane Opinie, System Transakcyjny": [trusted_opinion_on, transaction_system_on, trusted_opinion_id]
"Konfiguracja": [buy_now]
"Ustawienia generowania pliku xml": [use_product_code, use_man_code, use_ean_code, use_isbn_code, use_stock, use_attribute, description_type]
"Informacje o dostępności produktów": [_availability, stock_zero]
"ADS Tracker": [_ads_tracker_info_befour, ads_tracker, _ads_tracker_info_after]
fields:
trusted_opinion_on: {name: Włącz Zaufane Opinie, checked: false, type: checkbox}
transaction_system_on: {name: Włącz System Transakcyjny, checked: false, type: checkbox}
trusted_opinion_id: {name: Numer ID sklepu, params: size=34}
use_product_code: {name: Dodaj kod producenta na podstawie kodu produktu, checked: false, type: checkbox}
use_man_code: {name: Dodaj kod producenta, checked: false, type: checkbox}
use_ean_code: {name: Dodaj kod EAN, checked: false, type: checkbox}
use_isbn_code: {name: Dodaj kod ISBN, checked: false, type: checkbox}
use_stock: {name: Dodaj stan magazynowy, checked: false, type: checkbox}
use_attribute: {name: Dodaj atrybuty produktu, checked: false, type: checkbox}
stock_zero: {name: Nie eksportuj ze stanem 0, help: "Nie eksportuj produktów ze stanem magazynowym równym 0", checked: false, type: checkbox}
description_type:
name: Opis produktu
type: select
display: [full, short, none]
options:
full: {name: Pełny, value: full}
short: {name: Skrócony, value: short}
none: {name: Brak, value: none}
selected: full
availability: {hide_label: true}
ads_tracker: {name: Aktywuj, checked: false, type: checkbox}
ads_tracker_info_befour: {name: ""}
ads_tracker_info_after: {name: ""}
buy_now: {name: Domyślnie "Kup teraz", checked: false, type: checkbox}
actions:
_list: {name: Lista}
_save: {name: Zapisz}
menu: {use: list.menu}

View File

@@ -0,0 +1,5 @@
<?php
class stCeneoBackendBreadcrumbsBuilder extends autoStCeneoBackendBreadcrumbsBuilder
{
}

View File

@@ -0,0 +1,18 @@
<?php $config = stConfig::getInstance(sfContext::getInstance(), 'stCeneoBackend'); ?>
<?php
if ($config->get('ads_tracker')==1 && is_dir(sfConfig::get('sf_plugins_dir')."/appAdsTrackerPlugin")):?>
<?php
$c = new Criteria();
$c->add(AdsTrackerListPeer::PLUGIN_NAME, "ceneo");
$AdsTrackerList = AdsTrackerListPeer::doSelectOne($c);
if($AdsTrackerList):
?>
<?php echo __("Przejdź do ADS Trackera, aby obejrzeć raporty"); ?>:
<a href="<?php echo st_url_for('appAdsTrackerBackend/adsTrackerInfoStats/')."?id=".$AdsTrackerList->getId(); ?>"><?php echo __("Ceneo"); ?></a>
<?php endif; ?>
<?php endif; ?>

View File

@@ -0,0 +1,23 @@
<?php if (!is_dir(sfConfig::get('sf_plugins_dir')."/appAdsTrackerPlugin")): ?>
<?php echo __("Aby skorzystać z tej funkcji, potrzebujesz aplikacji ADS Tracker"); ?>:
<a target="_blank" href="https://www.sote.pl/ads-tracker.html?hash=e90a50c5a3a683e5e9dcc34a0ce1a2b3"><?php echo __("Zamów aplikację ADS Tracker"); ?></a>
<br/>
<style>
.off, .row_ads_tracker{
color: #999;
}
</style>
<script>
jQuery(function($) {
$("#config_ads_tracker").attr("disabled", true);
$("#config_ads_tracker").prop("checked", false );
});
</script>
<?php endif; ?>
<span class="off"><?php echo __("Raportuj wejścia i rozpoznawaj zamówienia osób, które weszły na stronę z porównywarki Ceneo."); ?></span>

View File

@@ -0,0 +1,9 @@
<input type="hidden" name="config[availability]" value="" />
<ul class="st_admin-item-list">
<?php foreach(stCeneo::getAvailabilities() as $availability):?>
<li style="padding-bottom: 7px;">
<span style="width: 240px; padding-top: 2px;"><?php echo __('Dostępność w sklepie').': "'.$availability->getAvailabilityName().'"';?></span>
<?php echo __('Dostępność w Ceneo');?>: <?php echo select_tag('config[availability_'.$availability->getId().']', options_for_select(stCeneo::getCeneoAvailabilities(), $config->get('availability_'.$availability->getId())));?>
</li>
<?php endforeach;?>
</ul>

View File

@@ -0,0 +1,3 @@
<?php if ($ceneo->getProductId()): ?>
<?php echo st_link_to($ceneo->getProduct()->getCode(), 'product/edit?id='.$ceneo->getProductId()); ?>
<?php endif; ?>

View File

@@ -0,0 +1,10 @@
<?php
if ($sf_request->getParameter('view') == 'product')
{
st_include_partial('stProduct/edit_menu', array('related_object' => $related_object, 'forward_parameters' => $forward_parameters));
}
else
{
include st_admin_get_template_path(__FILE__);
}
?>

View File

@@ -0,0 +1,22 @@
<?php use_helper('stProgressBar'); ?>
<div class="admin_form">
<fieldset >
<div class="content" style="text-align: center;">
<?php
if ($generate): ?>
<div id="generateXml">
<?php echo progress_bar('stCeneoGenerateXml', 'stCeneo', 'generate', $steps); ?>
</div>
<?php else : ?>
<?php echo __('Wciśnij przycisk "Generuj plik", aby rozpocząć proces tworzenia pliku exportu danych dla Ceneo.'); ?> <br>
<?php echo __('Może to potrwać nawet kilka minut w zależności od ilości produktów.'); ?>
<br><br>
<?php echo st_get_admin_button('file', __('Generuj plik'), 'ceneo/generateCustom?generate=1', array ('name' => 'sample_file', 'style' => 'text-align:center;')) ?>
<?php endif; ?>
</div>
</fieldset>
</div>

View File

@@ -0,0 +1,13 @@
<?php use_helper('stAdminGenerator'); ?>
<?php $stWebRequest = new stWebRequest(); ?>
<br />
<?php echo __('Plik został wygenerowany i znajduje się pod adresem:') ?>
<br>
<a href="http://<?php echo $stWebRequest->getHost() ?>/uploads/ceneo.xml" target="_blank">
http://<?php echo $stWebRequest->getHost() ?>/uploads/ceneo.xml
<a>
<br><br>
<?php echo st_get_admin_button('file', __('Pobierz'), '/uploads/ceneo.xml', array('download'=>null)); ?>

View File

@@ -0,0 +1,3 @@
<?php if ($ceneo->getProductId()): ?>
<?php echo st_link_to($ceneo->getProduct()->getName(), 'product/edit?id='.$ceneo->getProductId()); ?>
<?php endif; ?>