/**
  * Sort the options based off their position.
  *
  * @param array $options
  * @return array
  */
 protected function _sortOptions($options)
 {
     if (count($options)) {
         if (!$this->_read || !$this->_tbl_eav_attribute_option) {
             $resource = Mage::getSingleton('core/resource');
             $this->_read = $resource->getConnection('core_read');
             $this->_tbl_eav_attribute_option = $resource->getTableName('eav_attribute_option');
         }
         // Gather the option_id for all our current options
         $option_ids = array();
         foreach ($options as $option) {
             $option_ids[] = $option['id'];
             $var_name = 'option_id_' . $option['id'];
             ${$var_name} = $option;
         }
         $sql = "SELECT `option_id` FROM `{$this->_tbl_eav_attribute_option}` WHERE `option_id` IN('" . implode('\',\'', $option_ids) . "') ORDER BY `sort_order`";
         $result = $this->_read->fetchCol($sql);
         $options = array();
         foreach ($result as $option_id) {
             $var_name = 'option_id_' . $option_id;
             $options[] = ${$var_name};
         }
     }
     return $options;
 }
 /**
  * @param $name
  * @return bool
  * @throws Mage_Core_Exception
  */
 public function run($name)
 {
     $catId = $this->getCategoryId($name);
     $collection = $this->{$name}();
     // call a function of this class using the action param from the form
     $this->_deleteInCategory($catId);
     $sql = $this->_addProductsToCategorySQL($collection, $catId);
     try {
         $this->_writeConnection->query($sql);
         $this->_reindexCategoryAndProduct();
     } catch (Exception $e) {
         Mage::throwException($e);
     }
     return true;
 }
 /**
  * Delete a list of ids from the `core_url_rewrite` table
  *
  * @param $deleteList int[] - List of ids to delete
  * @return int              - Nr of ids deleted
  */
 protected function cleanRewrites($deleteList)
 {
     $count = 0;
     if (!empty($deleteList)) {
         $chunks = array_chunk($deleteList, 100);
         foreach ($chunks as $chunk) {
             $sql = sprintf('DELETE FROM %s WHERE `url_rewrite_id` IN (%s)', $this->writeAdapter->quoteIdentifier($this->table), $this->writeAdapter->quote($chunk));
             $stmt = $this->writeAdapter->query($sql);
             $count += $stmt->rowCount();
             $stmt->closeCursor();
         }
         echo ".";
         flush();
     }
     return $count;
 }
Example #4
0
 public function __construct($config)
 {
     if ($config instanceof Zend_Config) {
         $config = $config->toArray();
     }
     if (isset($config['secure_driver_options']) && is_array($config['secure_driver_options'])) {
         if (!isset($config['driver_options']) || !is_array($config['driver_options'])) {
             $config['driver_options'] = [];
         }
         foreach ($config['secure_driver_options'] as $key => $value) {
             $constant = 'PDO::' . $key;
             $constVal = constant($constant);
             if ($constVal !== null) {
                 $config['driver_options'][$constVal] = $value;
             }
         }
     }
     parent::__construct($config);
 }