Started price tab
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
|
||||
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
|
||||
<form name="thelia.admin.product.modification" class="Thelia\Form\ProductModificationForm"/>
|
||||
<form name="thelia.admin.product.details.modification" class="Thelia\Form\ProductDetailsModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
|
||||
<form name="thelia.admin.product.deletion" class="Thelia\Form\ProductModificationForm"/>
|
||||
|
||||
@@ -250,6 +250,23 @@ class BaseAdminController extends BaseController
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current edition currency ID, checking if a change was requested in the current request.
|
||||
*/
|
||||
protected function getCurrentEditionCurrency()
|
||||
{
|
||||
// Return the new language if a change is required.
|
||||
if (null !== $edit_currency_id = $this->getRequest()->get('edit_currency_id', null)) {
|
||||
|
||||
if (null !== $edit_currency = LangQuery::create()->findOneById($edit_currency_id)) {
|
||||
return $edit_currency;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise return the lang stored in session.
|
||||
return $this->getSession()->getAdminEditionCurrency();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current edition lang ID, checking if a change was requested in the current request.
|
||||
*/
|
||||
@@ -376,6 +393,9 @@ class BaseAdminController extends BaseController
|
||||
// Find the current edit language ID
|
||||
$edition_language = $this->getCurrentEditionLang();
|
||||
|
||||
// Find the current edit currency ID
|
||||
$edition_currency = $this->getCurrentEditionCurrency();
|
||||
|
||||
// Prepare common template variables
|
||||
$args = array_merge($args, array(
|
||||
'locale' => $session->getLang()->getLocale(),
|
||||
@@ -385,11 +405,16 @@ class BaseAdminController extends BaseController
|
||||
'edit_language_id' => $edition_language->getId(),
|
||||
'edit_language_locale' => $edition_language->getLocale(),
|
||||
|
||||
'edit_currency_id' => $edition_currency->getId(),
|
||||
|
||||
'current_url' => $this->getRequest()->getUri()
|
||||
));
|
||||
|
||||
// Update the current edition language in session
|
||||
$this->getSession()->setAdminEditionLang($edition_language);
|
||||
// Update the current edition language & currency in session
|
||||
$this->getSession()
|
||||
->setAdminEditionLang($edition_language)
|
||||
->setAdminEditionCurrency($edition_currency)
|
||||
;
|
||||
|
||||
// Render the template.
|
||||
try {
|
||||
|
||||
@@ -152,11 +152,7 @@ class ProductController extends AbstractCrudController
|
||||
->setVisible($formData['visible'])
|
||||
->setUrl($formData['url'])
|
||||
->setDefaultCategory($formData['default_category'])
|
||||
->setBasePrice($formData['price'])
|
||||
->setBaseWeight($formData['weight'])
|
||||
->setCurrencyId($formData['currency'])
|
||||
->setTaxRuleId($formData['tax_rule'])
|
||||
;
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
@@ -65,23 +65,6 @@ class Session extends BaseSession
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAdminEditionLang()
|
||||
{
|
||||
$lang = $this->get('thelia.admin.edition.lang');
|
||||
|
||||
if (null === $lang) {
|
||||
$lang = Lang::getDefaultLanguage();
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
public function setAdminEditionLang($langId)
|
||||
{
|
||||
$this->set('thelia.admin.edition.lang', $langId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCurrency(Currency $currency)
|
||||
{
|
||||
$this->set("thelia.current.currency", $currency);
|
||||
@@ -98,6 +81,43 @@ class Session extends BaseSession
|
||||
return $currency;
|
||||
}
|
||||
|
||||
// -- Admin lang and currency ----------------------------------------------
|
||||
|
||||
public function getAdminEditionCurrency()
|
||||
{
|
||||
$currency = $this->get('thelia.admin.edition.currency', null);
|
||||
|
||||
if (null === $currency) {
|
||||
$currency = Currency::getDefaultCurrency();
|
||||
}
|
||||
|
||||
return $currency;
|
||||
}
|
||||
|
||||
public function setAdminEditionCurrency($currencyId)
|
||||
{
|
||||
$this->set('thelia.admin.edition.currency', $currencyId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAdminEditionLang()
|
||||
{
|
||||
$lang = $this->get('thelia.admin.edition.lang');
|
||||
|
||||
if (null === $lang) {
|
||||
$lang = Lang::getDefaultLanguage();
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
public function setAdminEditionLang($lang)
|
||||
{
|
||||
$this->set('thelia.admin.edition.lang', $lang);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// -- Customer user --------------------------------------------------------
|
||||
|
||||
public function setCustomerUser(UserInterface $user)
|
||||
|
||||
@@ -63,27 +63,32 @@ class ProductCreationForm extends BaseForm
|
||||
"label" => Translator::getInstance()->trans("This product is online"),
|
||||
"label_attr" => array("for" => "visible_field")
|
||||
))
|
||||
->add("price", "number", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Product base price excluding taxes *"),
|
||||
"label_attr" => array("for" => "price_field")
|
||||
))
|
||||
->add("currency", "integer", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Price currency *"),
|
||||
"label_attr" => array("for" => "currency_field")
|
||||
))
|
||||
->add("tax_rule", "integer", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Tax rule for this product *"),
|
||||
"label_attr" => array("for" => "tax_rule_field")
|
||||
))
|
||||
->add("weight", "number", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Weight *"),
|
||||
"label_attr" => array("for" => "weight_field")
|
||||
))
|
||||
;
|
||||
|
||||
if (! $change_mode) {
|
||||
$this->formBuilder
|
||||
->add("price", "number", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Product base price excluding taxes *"),
|
||||
"label_attr" => array("for" => "price_field")
|
||||
))
|
||||
->add("currency", "integer", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Price currency *"),
|
||||
"label_attr" => array("for" => "currency_field")
|
||||
))
|
||||
->add("tax_rule", "integer", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Tax rule for this product *"),
|
||||
"label_attr" => array("for" => "tax_rule_field")
|
||||
))
|
||||
->add("weight", "number", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Weight *"),
|
||||
"label_attr" => array("for" => "weight_field")
|
||||
))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkDuplicateRef($value, ExecutionContextInterface $context)
|
||||
|
||||
90
core/lib/Thelia/Form/ProductDetailsModificationForm.php
Normal file
90
core/lib/Thelia/Form/ProductDetailsModificationForm.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class ProductDetailsModificationForm extends BaseForm
|
||||
{
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("id", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("Prodcut ID *"),
|
||||
"label_attr" => array("for" => "product_id_field"),
|
||||
"constraints" => array(new GreaterThan(array('value' => 0)))
|
||||
))
|
||||
->add("price", "number", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Product base price excluding taxes *"),
|
||||
"label_attr" => array("for" => "price_field")
|
||||
))
|
||||
->add("price_with_tax", "number", array(
|
||||
"label" => Translator::getInstance()->trans("Product base price including taxes *"),
|
||||
"label_attr" => array("for" => "price_with_tax_field")
|
||||
))
|
||||
->add("currency", "integer", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Price currency *"),
|
||||
"label_attr" => array("for" => "currency_field")
|
||||
))
|
||||
->add("tax_rule", "integer", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Tax rule for this product *"),
|
||||
"label_attr" => array("for" => "tax_rule_field")
|
||||
))
|
||||
->add("weight", "number", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Weight *"),
|
||||
"label_attr" => array("for" => "weight_field")
|
||||
))
|
||||
->add("quantity", "number", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Current quantity *"),
|
||||
"label_attr" => array("for" => "quantity_field")
|
||||
))
|
||||
->add("sale_price", "number", array(
|
||||
"label" => Translator::getInstance()->trans("Sale price *"),
|
||||
"label_attr" => array("for" => "price_with_tax_field")
|
||||
))
|
||||
->add("onsale", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("This product is on sale"),
|
||||
"label_attr" => array("for" => "onsale_field")
|
||||
))
|
||||
->add("isnew", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("Advertise this product as new"),
|
||||
"label_attr" => array("for" => "isnew_field")
|
||||
))
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_product_details_modification";
|
||||
}
|
||||
}
|
||||
@@ -98,10 +98,11 @@ class Product extends BaseProduct
|
||||
->filterByDefaultCategory(true)
|
||||
->findOne()
|
||||
;
|
||||
echo "newcat= $defaultCategoryId ";
|
||||
var_dump($productCategory);
|
||||
exit;
|
||||
if ($productCategory == null || $productCategory->getCategoryId() != $defaultCategoryId) {
|
||||
|
||||
if ($productCategory == null || $productCategory->getCategoryId() != $defaultCategoryId) {
|
||||
exit;
|
||||
// Delete the old default category
|
||||
if ($productCategory !== null) $productCategory->delete();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user