Exemplo n.º 1
0
function applyChanges( $module, $http, $productCategories = false )
{
    $errors = array();
    if ( $productCategories === false )
        $productCategories = eZProductCategory::fetchList();

    $db = eZDB::instance();
    $db->begin();
    foreach ( $productCategories as $cat )
    {
        $id = $cat->attribute( 'id' );

        if ( !$http->hasPostVariable( "category_name_" . $id ) )
            continue;

        $name = $http->postVariable( "category_name_" . $id );

        if ( !$name )
        {
            $errors[] = ezpI18n::tr( 'kernel/shop/productcategories', 'Empty category names are not allowed (corrected).' );
            continue;
        }

        $cat->setAttribute( 'name', $name );
        $cat->store();
    }
    $db->commit();

    return $errors;
}
 /**
  * Remove the given category and all references to it.
  *
  * \public
  * \static
  */
 static function removeByID($id)
 {
     $id = (int) $id;
     $db = eZDB::instance();
     $db->begin();
     // Delete references to the category from VAT charging rules.
     eZVatRule::removeReferencesToProductCategory($id);
     // Reset product category attribute for all products
     // that have been referencing the category.
     $ini = eZINI::instance('shop.ini');
     if ($ini->hasVariable('VATSettings', 'ProductCategoryAttribute') && ($categoryAttrName = $ini->variable('VATSettings', 'ProductCategoryAttribute'))) {
         $categoryAttrName = $db->escapeString($categoryAttrName);
         $query = "SELECT coa.id FROM ezcontentobject_attribute coa, ezcontentclass_attribute cca, ezcontentobject co " . "WHERE " . " cca.id=coa.contentclassattribute_id " . " AND coa.contentobject_id=co.id " . " AND cca.data_type_string='ezproductcategory' " . " AND cca.identifier='{$categoryAttrName}' " . " AND coa.version=co.current_version " . " AND coa.data_int={$id}";
         $rows = $db->arrayQuery($query);
         foreach ($rows as $row) {
             $query = "UPDATE ezcontentobject_attribute SET data_int=0, sort_key_int=0 WHERE id=" . (int) $row['id'];
             $db->query($query);
         }
     }
     // Remove the category itself.
     eZPersistentObject::removeObject(eZProductCategory::definition(), array("id" => $id));
     $db->commit();
 }
 function title($contentObjectAttribute, $name = null)
 {
     $categoryID = $contentObjectAttribute->attribute("data_int");
     $category = $categoryID > 0 ? eZProductCategory::fetch($categoryID) : false;
     return is_object($category) ? $category->attribute('name') : '';
 }
 function fetchProductCategoryList()
 {
     return array( 'result' => eZProductCategory::fetchList() );
 }
Exemplo n.º 5
0
<?php

/**
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version //autogentag//
 * @package kernel
 */
// Parameters: ruleID (optional)
$module = $Params['Module'];
$errors = false;
$errorHeader = false;
$productCategories = eZProductCategory::fetchList();
/**
 * Check entered data.
 *
 * \return list of errors found, or false if the data is ok.
 */
function checkEnteredData($country, $categories, $vatType, $productCategories, $ruleID)
{
    $errors = false;
    $errorHeader = '';
    /*
     * Check if the data was entered correctly.
     */
    if (!$country || !is_numeric($vatType)) {
        $errors = array();
        $errorHeader = ezpI18n::tr('kernel/shop/editvatrule', 'Invalid data entered');
        if (!$country) {
            $errors[] = ezpI18n::tr('kernel/shop/editvatrule', 'Choose a country.');
        }