Beispiel #1
0
 $config = array('insert' => array(), 'update' => array('General' => array('decimal_delim' => array('Currency decimal separator', 'Decimal separator for float values'), 'redirect_to_cart' => array('Redirect customer to cart when adding a product', 'Redirect customer to the cart page after a product is added to cart'), 'shop_closed' => array('Check this to close the shop temporarily', 'Close the shop temporarily'), 'thousand_delim' => array('Currency thousands separator', 'Thousands separator for float values'))), 'delete' => array());
 $objects = array();
 foreach ($config as $method => $tmp) {
     foreach ($tmp as $category => $data) {
         foreach ($data as $name => $value) {
             $object = \XLite\Core\Database::getRepo('\\XLite\\Model\\Config')->findOneBy(array('name' => $name, 'category' => $category));
             if (isset($object)) {
                 if ($method == 'update') {
                     list($oldLabel, $newLabel) = $value;
                     if ($object->getOptionName() === $oldLabel) {
                         $object->setOptionName($newLabel);
                     }
                 }
             } elseif ('insert' === $method) {
                 $object = new \XLite\Model\Config();
                 $object->setCategory($category);
                 $object->setName($name);
             }
             if (isset($object)) {
                 $objects[$method][] = $object;
             }
         }
     }
 }
 foreach ($objects as $method => $config) {
     \XLite\Core\Database::getRepo('\\XLite\\Model\\Config')->{$method . 'InBatch'}($config);
 }
 // Update shop_currency option type
 $option = \XLite\Core\Database::getRepo('\\XLite\\Model\\Config')->findOneBy(array('name' => 'shop_currency', 'category' => 'General'));
 if (isset($option)) {
     $option->setType('');