コード例 #1
0
ファイル: store.go プロジェクト: bom-d-van/csfw
// Load uses a dbr session to load all data from the core_store table into the current slice.
// The variadic 2nd argument can be a call back function to manipulate the select.
// Additional columns or joins cannot be added. This method receiver should only be used in development.
// @see https://github.com/magento/magento2/blob/0.74.0-beta7/app%2Fcode%2FMagento%2FStore%2FModel%2FResource%2FStore%2FCollection.php#L147
// regarding the sort order.
func (s *TableStoreSlice) Load(dbrSess dbr.SessionRunner, cbs ...csdb.DbrSelectCb) (int, error) {
	return csdb.LoadSlice(dbrSess, TableCollection, TableIndexStore, &(*s), append(cbs, func(sb *dbr.SelectBuilder) *dbr.SelectBuilder {
		sb.OrderBy("CASE WHEN main_table.store_id = 0 THEN 0 ELSE 1 END ASC")
		sb.OrderBy("main_table.sort_order ASC")
		return sb.OrderBy("main_table.name ASC")
	})...)
}
コード例 #2
0
ファイル: manager.go プロジェクト: optimuse/csfw
// ApplyCoreConfigData reads the table core_config_data into the Manager and overrides
// existing values. If the column value is NULL entry will be ignored.
func (m *Manager) ApplyCoreConfigData(dbrSess dbr.SessionRunner) error {
	var ccd TableCoreConfigDataSlice
	rows, err := csdb.LoadSlice(dbrSess, TableCollection, TableIndexCoreConfigData, &ccd)
	if log.IsDebug() {
		log.Debug("config.Manager.ApplyCoreConfigData", "rows", rows)
	}
	if err != nil {
		return log.Error("config.Manager.ApplyCoreConfigData.LoadSlice", "err", err)
	}

	for _, cd := range ccd {
		if cd.Value.Valid {
			// ScopeID(cd.ScopeID) because cd.ScopeID is a struct field and cannot satisfy interface ScopeIDer
			m.Write(Path(cd.Path), Scope(GetScopeGroup(cd.Scope), ScopeID(cd.ScopeID)))
		}
	}
	return nil
}
コード例 #3
0
ファイル: manager.go プロジェクト: levcom/csfw
// ApplyCoreConfigData reads the table core_config_data into the Manager and overrides
// existing values. If the column value is NULL entry will be ignored.
func (m *Manager) ApplyCoreConfigData(dbrSess dbr.SessionRunner) error {
	var ccd TableCoreConfigDataSlice
	rows, err := csdb.LoadSlice(dbrSess, TableCollection, TableIndexCoreConfigData, &ccd)
	if PkgLog.IsDebug() {
		PkgLog.Debug("config.Manager.ApplyCoreConfigData", "rows", rows)
	}
	if err != nil {
		if PkgLog.IsDebug() {
			PkgLog.Debug("config.Manager.ApplyCoreConfigData.LoadSlice", "err", err)
		}
		return errgo.Mask(err)
	}

	for _, cd := range ccd {
		if cd.Value.Valid {
			// scope.ID(cd.ScopeID) because cd.ScopeID is a struct field and cannot satisfy interface scope.IDer
			if err := m.Write(Path(cd.Path), Scope(scope.FromString(cd.Scope), cd.ScopeID)); err != nil {
				return errgo.Mask(err)
			}
		}
	}
	return nil
}
コード例 #4
0
ファイル: service.go プロジェクト: joao-parana/csfw
// ApplyCoreConfigData reads the table core_config_data into the Service and overrides
// existing values. If the column `value` is NULL entry will be ignored. It returns the
// loadedRows which are all rows from the table and the writtenRows which are the applied
// config values where a value is valid.
func (s *Service) ApplyCoreConfigData(dbrSess dbr.SessionRunner) (loadedRows, writtenRows int, err error) {
	var ccd TableCoreConfigDataSlice
	loadedRows, err = csdb.LoadSlice(dbrSess, TableCollection, TableIndexCoreConfigData, &ccd)
	if PkgLog.IsDebug() {
		PkgLog.Debug("config.Service.ApplyCoreConfigData", "rows", loadedRows)
	}
	if err != nil {
		if PkgLog.IsDebug() {
			PkgLog.Debug("config.Service.ApplyCoreConfigData.LoadSlice", "err", err)
		}
		return loadedRows, writtenRows, errgo.Mask(err)
	}

	for _, cd := range ccd {
		if cd.Value.Valid {
			// scope.ID(cd.ScopeID) because cd.ScopeID is a struct field and cannot satisfy interface scope.IDer
			if err := s.Write(Path(cd.Path), Scope(scope.FromString(cd.Scope), cd.ScopeID), Value(cd.Value.String)); err != nil {
				return loadedRows, writtenRows, errgo.Mask(err)
			}
			writtenRows++
		}
	}
	return loadedRows, writtenRows, err
}
コード例 #5
0
ファイル: tables_fallback.go プロジェクト: joao-parana/csfw
// parentSQLSelect fills this slice with data from the database.
// Generated via tableToStruct.
func (s *TableStoreSlice) parentSQLSelect(dbrSess dbr.SessionRunner, cbs ...dbr.SelectCb) (int, error) {
	return csdb.LoadSlice(dbrSess, TableCollection, TableIndexStore, &(*s), cbs...)
}
コード例 #6
0
ファイル: group.go プロジェクト: bom-d-van/csfw
// Load uses a dbr session to load all data from the core_store_group table into the current slice.
// The variadic 2nd argument can be a call back function to manipulate the select.
// Additional columns or joins cannot be added. This method receiver should only be used in development.
// @see app/code/Magento/Store/Model/Resource/Group/Collection.php::_beforeLoad()
func (s *TableGroupSlice) Load(dbrSess dbr.SessionRunner, cbs ...csdb.DbrSelectCb) (int, error) {
	return csdb.LoadSlice(dbrSess, TableCollection, TableIndexGroup, &(*s), append(cbs, func(sb *dbr.SelectBuilder) *dbr.SelectBuilder {
		return sb.OrderBy("main_table.name ASC")
	})...)
}