Exemple #1
0
 static function priceAttributeIdentifier($productClass)
 {
     $identifier = '';
     $classAttribute = eZShopFunctions::priceAttribute($productClass);
     if (is_object($classAttribute)) {
         $identifier = $classAttribute->attribute('identifier');
     }
     return $identifier;
 }
$db->begin();
foreach ($classList as $class) {
    if (eZShopFunctions::isSimplePriceClass($class)) {
        $classID = $class->attribute('id');
        $objectListCount = eZContentObject::fetchSameClassListCount($classID);
        if ($objectListCount == 0) {
            $cli->output("No objects found for '" . $class->attribute('name') . "' class");
            continue;
        }
        $cli->output("Processing objects of the '" . $class->attribute('name') . "' class");
        $defaultCurrency = currencyForLocale();
        if (!$defaultCurrency) {
            $script->shutdown(1);
        }
        $defaultCurrencyCode = $defaultCurrency->attribute('code');
        $priceClassAttribute = eZShopFunctions::priceAttribute($class);
        $priceClassAttributeID = $priceClassAttribute->attribute('id');
        // replace 'ezprice' class attribute with 'ezmultiprice'.
        $priceClassAttribute->setAttribute('data_type_string', 'ezmultiprice');
        $priceClassAttribute->setAttribute(eZMultiPriceType::DEFAULT_CURRENCY_CODE_FIELD, $defaultCurrencyCode);
        $priceClassAttribute->store();
        unset($GLOBALS['eZContentClassAttributeCache'][$priceClassAttributeID]);
        // update objects
        $offset = 0;
        $limit = 1000;
        $cli->output('Converting', false);
        while ($offset < $objectListCount) {
            $objectList = eZContentObject::fetchSameClassList($class->attribute('id'), true, $offset, $limit);
            $offset += count($objectList);
            foreach ($objectList as $object) {
                $contentObjectID = $object->attribute('id');