<?php

namespace ArtabanMarketplace\Model\Base;

use \DateTime;
use \Exception;
use \PDO;
use ArtabanMarketplace\Model\AmpSeller as ChildAmpSeller;
use ArtabanMarketplace\Model\AmpSellerAdmin as ChildAmpSellerAdmin;
use ArtabanMarketplace\Model\AmpSellerAdminQuery as ChildAmpSellerAdminQuery;
use ArtabanMarketplace\Model\AmpSellerAdminVersionQuery as ChildAmpSellerAdminVersionQuery;
use ArtabanMarketplace\Model\AmpSellerI18n as ChildAmpSellerI18n;
use ArtabanMarketplace\Model\AmpSellerI18nQuery as ChildAmpSellerI18nQuery;
use ArtabanMarketplace\Model\AmpSellerImage as ChildAmpSellerImage;
use ArtabanMarketplace\Model\AmpSellerImageQuery as ChildAmpSellerImageQuery;
use ArtabanMarketplace\Model\AmpSellerOrder as ChildAmpSellerOrder;
use ArtabanMarketplace\Model\AmpSellerOrderQuery as ChildAmpSellerOrderQuery;
use ArtabanMarketplace\Model\AmpSellerOrderVersionQuery as ChildAmpSellerOrderVersionQuery;
use ArtabanMarketplace\Model\AmpSellerProduct as ChildAmpSellerProduct;
use ArtabanMarketplace\Model\AmpSellerProductQuery as ChildAmpSellerProductQuery;
use ArtabanMarketplace\Model\AmpSellerProductVersionQuery as ChildAmpSellerProductVersionQuery;
use ArtabanMarketplace\Model\AmpSellerQuery as ChildAmpSellerQuery;
use ArtabanMarketplace\Model\AmpSellerVersion as ChildAmpSellerVersion;
use ArtabanMarketplace\Model\AmpSellerVersionQuery as ChildAmpSellerVersionQuery;
use ArtabanMarketplace\Model\Map\AmpSellerAdminVersionTableMap;
use ArtabanMarketplace\Model\Map\AmpSellerOrderVersionTableMap;
use ArtabanMarketplace\Model\Map\AmpSellerProductVersionTableMap;
use ArtabanMarketplace\Model\Map\AmpSellerTableMap;
use ArtabanMarketplace\Model\Map\AmpSellerVersionTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\BadMethodCallException;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Parser\AbstractParser;
use Propel\Runtime\Util\PropelDateTime;
use Thelia\Model\Country as ChildCountry;
use Thelia\Model\CountryQuery;

abstract class AmpSeller implements ActiveRecordInterface
{
    /**
     * TableMap class name
     */
    const TABLE_MAP = '\\ArtabanMarketplace\\Model\\Map\\AmpSellerTableMap';


    /**
     * attribute to determine if this object has previously been saved.
     * @var boolean
     */
    protected $new = true;

    /**
     * attribute to determine whether this object has been deleted.
     * @var boolean
     */
    protected $deleted = false;

    /**
     * The columns that have been modified in current object.
     * Tracking modified columns allows us to only update modified columns.
     * @var array
     */
    protected $modifiedColumns = array();

    /**
     * The (virtual) columns that are added at runtime
     * The formatters can add supplementary columns based on a resultset
     * @var array
     */
    protected $virtualColumns = array();

    /**
     * The value for the id field.
     * @var        int
     */
    protected $id;

    /**
     * The value for the ref field.
     * @var        string
     */
    protected $ref;

    /**
     * The value for the visible field.
     * Note: this column has a database default value of: 0
     * @var        int
     */
    protected $visible;

    /**
     * The value for the address1 field.
     * @var        string
     */
    protected $address1;

    /**
     * The value for the address2 field.
     * @var        string
     */
    protected $address2;

    /**
     * The value for the address3 field.
     * @var        string
     */
    protected $address3;

    /**
     * The value for the zipcode field.
     * @var        string
     */
    protected $zipcode;

    /**
     * The value for the city field.
     * @var        string
     */
    protected $city;

    /**
     * The value for the country_id field.
     * @var        int
     */
    protected $country_id;

    /**
     * The value for the email field.
     * @var        string
     */
    protected $email;

    /**
     * The value for the phone field.
     * @var        string
     */
    protected $phone;

    /**
     * The value for the fax field.
     * @var        string
     */
    protected $fax;

    /**
     * The value for the url field.
     * @var        string
     */
    protected $url;

    /**
     * The value for the facebook field.
     * @var        string
     */
    protected $facebook;

    /**
     * The value for the twitter field.
     * @var        string
     */
    protected $twitter;

    /**
     * The value for the pinterest field.
     * @var        string
     */
    protected $pinterest;

    /**
     * The value for the google field.
     * @var        string
     */
    protected $google;

    /**
     * The value for the youtube field.
     * @var        string
     */
    protected $youtube;

    /**
     * The value for the instagram field.
     * @var        string
     */
    protected $instagram;

    /**
     * The value for the latitude field.
     * Note: this column has a database default value of: '0'
     * @var        string
     */
    protected $latitude;

    /**
     * The value for the longitude field.
     * Note: this column has a database default value of: '0'
     * @var        string
     */
    protected $longitude;

    /**
     * The value for the created_at field.
     * @var        string
     */
    protected $created_at;

    /**
     * The value for the updated_at field.
     * @var        string
     */
    protected $updated_at;

    /**
     * The value for the version field.
     * Note: this column has a database default value of: 0
     * @var        int
     */
    protected $version;

    /**
     * The value for the version_created_at field.
     * @var        string
     */
    protected $version_created_at;

    /**
     * The value for the version_created_by field.
     * @var        string
     */
    protected $version_created_by;

    /**
     * @var        Country
     */
    protected $aCountry;

    /**
     * @var        ObjectCollection|ChildAmpSellerAdmin[] Collection to store aggregation of ChildAmpSellerAdmin objects.
     */
    protected $collAmpSellerAdmins;
    protected $collAmpSellerAdminsPartial;

    /**
     * @var        ObjectCollection|ChildAmpSellerProduct[] Collection to store aggregation of ChildAmpSellerProduct objects.
     */
    protected $collAmpSellerProducts;
    protected $collAmpSellerProductsPartial;

    /**
     * @var        ObjectCollection|ChildAmpSellerImage[] Collection to store aggregation of ChildAmpSellerImage objects.
     */
    protected $collAmpSellerImages;
    protected $collAmpSellerImagesPartial;

    /**
     * @var        ObjectCollection|ChildAmpSellerOrder[] Collection to store aggregation of ChildAmpSellerOrder objects.
     */
    protected $collAmpSellerOrders;
    protected $collAmpSellerOrdersPartial;

    /**
     * @var        ObjectCollection|ChildAmpSellerI18n[] Collection to store aggregation of ChildAmpSellerI18n objects.
     */
    protected $collAmpSellerI18ns;
    protected $collAmpSellerI18nsPartial;

    /**
     * @var        ObjectCollection|ChildAmpSellerVersion[] Collection to store aggregation of ChildAmpSellerVersion objects.
     */
    protected $collAmpSellerVersions;
    protected $collAmpSellerVersionsPartial;

    /**
     * Flag to prevent endless save loop, if this object is referenced
     * by another object which falls in this transaction.
     *
     * @var boolean
     */
    protected $alreadyInSave = false;

    // i18n behavior

    /**
     * Current locale
     * @var        string
     */
    protected $currentLocale = 'en_US';

    /**
     * Current translation objects
     * @var        array[ChildAmpSellerI18n]
     */
    protected $currentTranslations;

    // versionable behavior


    /**
     * @var bool
     */
    protected $enforceVersion = false;

    /**
     * An array of objects scheduled for deletion.
     * @var ObjectCollection
     */
    protected $ampSellerAdminsScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var ObjectCollection
     */
    protected $ampSellerProductsScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var ObjectCollection
     */
    protected $ampSellerImagesScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var ObjectCollection
     */
    protected $ampSellerOrdersScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var ObjectCollection
     */
    protected $ampSellerI18nsScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var ObjectCollection
     */
    protected $ampSellerVersionsScheduledForDeletion = null;

    /**
     * Applies default values to this object.
     * This method should be called from the object's constructor (or
     * equivalent initialization method).
     * @see __construct()
     */
    public function applyDefaultValues()
    {
        $this->visible = 0;
        $this->latitude = '0';
        $this->longitude = '0';
        $this->version = 0;
    }

    /**
     * Initializes internal state of ArtabanMarketplace\Model\Base\AmpSeller object.
     * @see applyDefaults()
     */
    public function __construct()
    {
        $this->applyDefaultValues();
    }

    /**
     * Returns whether the object has been modified.
     *
     * @return boolean True if the object has been modified.
     */
    public function isModified()
    {
        return !!$this->modifiedColumns;
    }

    /**
     * Has specified column been modified?
     *
     * @param  string  $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
     * @return boolean True if $col has been modified.
     */
    public function isColumnModified($col)
    {
        return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
    }

    /**
     * Get the columns that have been modified in this object.
     * @return array A unique list of the modified column names for this object.
     */
    public function getModifiedColumns()
    {
        return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
    }

    /**
     * Returns whether the object has ever been saved.  This will
     * be false, if the object was retrieved from storage or was created
     * and then saved.
     *
     * @return boolean true, if the object has never been persisted.
     */
    public function isNew()
    {
        return $this->new;
    }

    /**
     * Setter for the isNew attribute.  This method will be called
     * by Propel-generated children and objects.
     *
     * @param boolean $b the state of the object.
     */
    public function setNew($b)
    {
        $this->new = (Boolean) $b;
    }

    /**
     * Whether this object has been deleted.
     * @return boolean The deleted state of this object.
     */
    public function isDeleted()
    {
        return $this->deleted;
    }

    /**
     * Specify whether this object has been deleted.
     * @param  boolean $b The deleted state of this object.
     * @return void
     */
    public function setDeleted($b)
    {
        $this->deleted = (Boolean) $b;
    }

    /**
     * Sets the modified state for the object to be false.
     * @param  string $col If supplied, only the specified column is reset.
     * @return void
     */
    public function resetModified($col = null)
    {
        if (null !== $col) {
            if (isset($this->modifiedColumns[$col])) {
                unset($this->modifiedColumns[$col]);
            }
        } else {
            $this->modifiedColumns = array();
        }
    }

    /**
     * Compares this with another <code>AmpSeller</code> instance.  If
     * <code>obj</code> is an instance of <code>AmpSeller</code>, delegates to
     * <code>equals(AmpSeller)</code>.  Otherwise, returns <code>false</code>.
     *
     * @param  mixed   $obj The object to compare to.
     * @return boolean Whether equal to the object specified.
     */
    public function equals($obj)
    {
        $thisclazz = get_class($this);
        if (!is_object($obj) || !($obj instanceof $thisclazz)) {
            return false;
        }

        if ($this === $obj) {
            return true;
        }

        if (null === $this->getPrimaryKey()
            || null === $obj->getPrimaryKey())  {
            return false;
        }

        return $this->getPrimaryKey() === $obj->getPrimaryKey();
    }

    /**
     * If the primary key is not null, return the hashcode of the
     * primary key. Otherwise, return the hash code of the object.
     *
     * @return int Hashcode
     */
    public function hashCode()
    {
        if (null !== $this->getPrimaryKey()) {
            return crc32(serialize($this->getPrimaryKey()));
        }

        return crc32(serialize(clone $this));
    }

    /**
     * Get the associative array of the virtual columns in this object
     *
     * @return array
     */
    public function getVirtualColumns()
    {
        return $this->virtualColumns;
    }

    /**
     * Checks the existence of a virtual column in this object
     *
     * @param  string  $name The virtual column name
     * @return boolean
     */
    public function hasVirtualColumn($name)
    {
        return array_key_exists($name, $this->virtualColumns);
    }

    /**
     * Get the value of a virtual column in this object
     *
     * @param  string $name The virtual column name
     * @return mixed
     *
     * @throws PropelException
     */
    public function getVirtualColumn($name)
    {
        if (!$this->hasVirtualColumn($name)) {
            throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
        }

        return $this->virtualColumns[$name];
    }

    /**
     * Set the value of a virtual column in this object
     *
     * @param string $name  The virtual column name
     * @param mixed  $value The value to give to the virtual column
     *
     * @return AmpSeller The current object, for fluid interface
     */
    public function setVirtualColumn($name, $value)
    {
        $this->virtualColumns[$name] = $value;

        return $this;
    }

    /**
     * Logs a message using Propel::log().
     *
     * @param  string  $msg
     * @param  int     $priority One of the Propel::LOG_* logging levels
     * @return boolean
     */
    protected function log($msg, $priority = Propel::LOG_INFO)
    {
        return Propel::log(get_class($this) . ': ' . $msg, $priority);
    }

    /**
     * Populate the current object from a string, using a given parser format
     * <code>
     * $book = new Book();
     * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
     * </code>
     *
     * @param mixed $parser A AbstractParser instance,
     *                       or a format name ('XML', 'YAML', 'JSON', 'CSV')
     * @param string $data The source data to import from
     *
     * @return AmpSeller The current object, for fluid interface
     */
    public function importFrom($parser, $data)
    {
        if (!$parser instanceof AbstractParser) {
            $parser = AbstractParser::getParser($parser);
        }

        $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);

        return $this;
    }

    /**
     * Export the current object properties to a string, using a given parser format
     * <code>
     * $book = BookQuery::create()->findPk(9012);
     * echo $book->exportTo('JSON');
     *  => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
     * </code>
     *
     * @param  mixed   $parser                 A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
     * @param  boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
     * @return string  The exported data
     */
    public function exportTo($parser, $includeLazyLoadColumns = true)
    {
        if (!$parser instanceof AbstractParser) {
            $parser = AbstractParser::getParser($parser);
        }

        return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
    }

    /**
     * Clean up internal collections prior to serializing
     * Avoids recursive loops that turn into segmentation faults when serializing
     */
    public function __sleep()
    {
        $this->clearAllReferences();

        return array_keys(get_object_vars($this));
    }

    /**
     * Get the [id] column value.
     *
     * @return   int
     */
    public function getId()
    {

        return $this->id;
    }

    /**
     * Get the [ref] column value.
     *
     * @return   string
     */
    public function getRef()
    {

        return $this->ref;
    }

    /**
     * Get the [visible] column value.
     *
     * @return   int
     */
    public function getVisible()
    {

        return $this->visible;
    }

    /**
     * Get the [address1] column value.
     *
     * @return   string
     */
    public function getAddress1()
    {

        return $this->address1;
    }

    /**
     * Get the [address2] column value.
     *
     * @return   string
     */
    public function getAddress2()
    {

        return $this->address2;
    }

    /**
     * Get the [address3] column value.
     *
     * @return   string
     */
    public function getAddress3()
    {

        return $this->address3;
    }

    /**
     * Get the [zipcode] column value.
     *
     * @return   string
     */
    public function getZipcode()
    {

        return $this->zipcode;
    }

    /**
     * Get the [city] column value.
     *
     * @return   string
     */
    public function getCity()
    {

        return $this->city;
    }

    /**
     * Get the [country_id] column value.
     *
     * @return   int
     */
    public function getCountryId()
    {

        return $this->country_id;
    }

    /**
     * Get the [email] column value.
     *
     * @return   string
     */
    public function getEmail()
    {

        return $this->email;
    }

    /**
     * Get the [phone] column value.
     *
     * @return   string
     */
    public function getPhone()
    {

        return $this->phone;
    }

    /**
     * Get the [fax] column value.
     *
     * @return   string
     */
    public function getFax()
    {

        return $this->fax;
    }

    /**
     * Get the [url] column value.
     *
     * @return   string
     */
    public function getUrl()
    {

        return $this->url;
    }

    /**
     * Get the [facebook] column value.
     *
     * @return   string
     */
    public function getFacebook()
    {

        return $this->facebook;
    }

    /**
     * Get the [twitter] column value.
     *
     * @return   string
     */
    public function getTwitter()
    {

        return $this->twitter;
    }

    /**
     * Get the [pinterest] column value.
     *
     * @return   string
     */
    public function getPinterest()
    {

        return $this->pinterest;
    }

    /**
     * Get the [google] column value.
     *
     * @return   string
     */
    public function getGoogle()
    {

        return $this->google;
    }

    /**
     * Get the [youtube] column value.
     *
     * @return   string
     */
    public function getYoutube()
    {

        return $this->youtube;
    }

    /**
     * Get the [instagram] column value.
     *
     * @return   string
     */
    public function getInstagram()
    {

        return $this->instagram;
    }

    /**
     * Get the [latitude] column value.
     *
     * @return   string
     */
    public function getLatitude()
    {

        return $this->latitude;
    }

    /**
     * Get the [longitude] column value.
     *
     * @return   string
     */
    public function getLongitude()
    {

        return $this->longitude;
    }

    /**
     * Get the [optionally formatted] temporal [created_at] column value.
     *
     *
     * @param      string $format The date/time format string (either date()-style or strftime()-style).
     *                            If format is NULL, then the raw \DateTime object will be returned.
     *
     * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
     *
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getCreatedAt($format = NULL)
    {
        if ($format === null) {
            return $this->created_at;
        } else {
            return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
        }
    }

    /**
     * Get the [optionally formatted] temporal [updated_at] column value.
     *
     *
     * @param      string $format The date/time format string (either date()-style or strftime()-style).
     *                            If format is NULL, then the raw \DateTime object will be returned.
     *
     * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
     *
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getUpdatedAt($format = NULL)
    {
        if ($format === null) {
            return $this->updated_at;
        } else {
            return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
        }
    }

    /**
     * Get the [version] column value.
     *
     * @return   int
     */
    public function getVersion()
    {

        return $this->version;
    }

    /**
     * Get the [optionally formatted] temporal [version_created_at] column value.
     *
     *
     * @param      string $format The date/time format string (either date()-style or strftime()-style).
     *                            If format is NULL, then the raw \DateTime object will be returned.
     *
     * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
     *
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getVersionCreatedAt($format = NULL)
    {
        if ($format === null) {
            return $this->version_created_at;
        } else {
            return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null;
        }
    }

    /**
     * Get the [version_created_by] column value.
     *
     * @return   string
     */
    public function getVersionCreatedBy()
    {

        return $this->version_created_by;
    }

    /**
     * Set the value of [id] column.
     *
     * @param      int $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->id !== $v) {
            $this->id = $v;
            $this->modifiedColumns[AmpSellerTableMap::ID] = true;
        }


        return $this;
    } // setId()

    /**
     * Set the value of [ref] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setRef($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->ref !== $v) {
            $this->ref = $v;
            $this->modifiedColumns[AmpSellerTableMap::REF] = true;
        }


        return $this;
    } // setRef()

    /**
     * Set the value of [visible] column.
     *
     * @param      int $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setVisible($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->visible !== $v) {
            $this->visible = $v;
            $this->modifiedColumns[AmpSellerTableMap::VISIBLE] = true;
        }


        return $this;
    } // setVisible()

    /**
     * Set the value of [address1] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setAddress1($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->address1 !== $v) {
            $this->address1 = $v;
            $this->modifiedColumns[AmpSellerTableMap::ADDRESS1] = true;
        }


        return $this;
    } // setAddress1()

    /**
     * Set the value of [address2] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setAddress2($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->address2 !== $v) {
            $this->address2 = $v;
            $this->modifiedColumns[AmpSellerTableMap::ADDRESS2] = true;
        }


        return $this;
    } // setAddress2()

    /**
     * Set the value of [address3] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setAddress3($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->address3 !== $v) {
            $this->address3 = $v;
            $this->modifiedColumns[AmpSellerTableMap::ADDRESS3] = true;
        }


        return $this;
    } // setAddress3()

    /**
     * Set the value of [zipcode] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setZipcode($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->zipcode !== $v) {
            $this->zipcode = $v;
            $this->modifiedColumns[AmpSellerTableMap::ZIPCODE] = true;
        }


        return $this;
    } // setZipcode()

    /**
     * Set the value of [city] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setCity($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->city !== $v) {
            $this->city = $v;
            $this->modifiedColumns[AmpSellerTableMap::CITY] = true;
        }


        return $this;
    } // setCity()

    /**
     * Set the value of [country_id] column.
     *
     * @param      int $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setCountryId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->country_id !== $v) {
            $this->country_id = $v;
            $this->modifiedColumns[AmpSellerTableMap::COUNTRY_ID] = true;
        }

        if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
            $this->aCountry = null;
        }


        return $this;
    } // setCountryId()

    /**
     * Set the value of [email] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setEmail($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->email !== $v) {
            $this->email = $v;
            $this->modifiedColumns[AmpSellerTableMap::EMAIL] = true;
        }


        return $this;
    } // setEmail()

    /**
     * Set the value of [phone] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setPhone($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->phone !== $v) {
            $this->phone = $v;
            $this->modifiedColumns[AmpSellerTableMap::PHONE] = true;
        }


        return $this;
    } // setPhone()

    /**
     * Set the value of [fax] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setFax($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->fax !== $v) {
            $this->fax = $v;
            $this->modifiedColumns[AmpSellerTableMap::FAX] = true;
        }


        return $this;
    } // setFax()

    /**
     * Set the value of [url] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setUrl($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->url !== $v) {
            $this->url = $v;
            $this->modifiedColumns[AmpSellerTableMap::URL] = true;
        }


        return $this;
    } // setUrl()

    /**
     * Set the value of [facebook] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setFacebook($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->facebook !== $v) {
            $this->facebook = $v;
            $this->modifiedColumns[AmpSellerTableMap::FACEBOOK] = true;
        }


        return $this;
    } // setFacebook()

    /**
     * Set the value of [twitter] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setTwitter($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->twitter !== $v) {
            $this->twitter = $v;
            $this->modifiedColumns[AmpSellerTableMap::TWITTER] = true;
        }


        return $this;
    } // setTwitter()

    /**
     * Set the value of [pinterest] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setPinterest($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->pinterest !== $v) {
            $this->pinterest = $v;
            $this->modifiedColumns[AmpSellerTableMap::PINTEREST] = true;
        }


        return $this;
    } // setPinterest()

    /**
     * Set the value of [google] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setGoogle($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->google !== $v) {
            $this->google = $v;
            $this->modifiedColumns[AmpSellerTableMap::GOOGLE] = true;
        }


        return $this;
    } // setGoogle()

    /**
     * Set the value of [youtube] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setYoutube($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->youtube !== $v) {
            $this->youtube = $v;
            $this->modifiedColumns[AmpSellerTableMap::YOUTUBE] = true;
        }


        return $this;
    } // setYoutube()

    /**
     * Set the value of [instagram] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setInstagram($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->instagram !== $v) {
            $this->instagram = $v;
            $this->modifiedColumns[AmpSellerTableMap::INSTAGRAM] = true;
        }


        return $this;
    } // setInstagram()

    /**
     * Set the value of [latitude] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setLatitude($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->latitude !== $v) {
            $this->latitude = $v;
            $this->modifiedColumns[AmpSellerTableMap::LATITUDE] = true;
        }


        return $this;
    } // setLatitude()

    /**
     * Set the value of [longitude] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setLongitude($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->longitude !== $v) {
            $this->longitude = $v;
            $this->modifiedColumns[AmpSellerTableMap::LONGITUDE] = true;
        }


        return $this;
    } // setLongitude()

    /**
     * Sets the value of [created_at] column to a normalized version of the date/time value specified.
     *
     * @param      mixed $v string, integer (timestamp), or \DateTime value.
     *               Empty strings are treated as NULL.
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setCreatedAt($v)
    {
        $dt = PropelDateTime::newInstance($v, null, '\DateTime');
        if ($this->created_at !== null || $dt !== null) {
            if ($dt !== $this->created_at) {
                $this->created_at = $dt;
                $this->modifiedColumns[AmpSellerTableMap::CREATED_AT] = true;
            }
        } // if either are not null


        return $this;
    } // setCreatedAt()

    /**
     * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
     *
     * @param      mixed $v string, integer (timestamp), or \DateTime value.
     *               Empty strings are treated as NULL.
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setUpdatedAt($v)
    {
        $dt = PropelDateTime::newInstance($v, null, '\DateTime');
        if ($this->updated_at !== null || $dt !== null) {
            if ($dt !== $this->updated_at) {
                $this->updated_at = $dt;
                $this->modifiedColumns[AmpSellerTableMap::UPDATED_AT] = true;
            }
        } // if either are not null


        return $this;
    } // setUpdatedAt()

    /**
     * Set the value of [version] column.
     *
     * @param      int $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setVersion($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->version !== $v) {
            $this->version = $v;
            $this->modifiedColumns[AmpSellerTableMap::VERSION] = true;
        }


        return $this;
    } // setVersion()

    /**
     * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
     *
     * @param      mixed $v string, integer (timestamp), or \DateTime value.
     *               Empty strings are treated as NULL.
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setVersionCreatedAt($v)
    {
        $dt = PropelDateTime::newInstance($v, null, '\DateTime');
        if ($this->version_created_at !== null || $dt !== null) {
            if ($dt !== $this->version_created_at) {
                $this->version_created_at = $dt;
                $this->modifiedColumns[AmpSellerTableMap::VERSION_CREATED_AT] = true;
            }
        } // if either are not null


        return $this;
    } // setVersionCreatedAt()

    /**
     * Set the value of [version_created_by] column.
     *
     * @param      string $v new value
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function setVersionCreatedBy($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->version_created_by !== $v) {
            $this->version_created_by = $v;
            $this->modifiedColumns[AmpSellerTableMap::VERSION_CREATED_BY] = true;
        }


        return $this;
    } // setVersionCreatedBy()

    /**
     * Indicates whether the columns in this object are only set to default values.
     *
     * This method can be used in conjunction with isModified() to indicate whether an object is both
     * modified _and_ has some values set which are non-default.
     *
     * @return boolean Whether the columns in this object are only been set with default values.
     */
    public function hasOnlyDefaultValues()
    {
            if ($this->visible !== 0) {
                return false;
            }

            if ($this->latitude !== '0') {
                return false;
            }

            if ($this->longitude !== '0') {
                return false;
            }

            if ($this->version !== 0) {
                return false;
            }

        // otherwise, everything was equal, so return TRUE
        return true;
    } // hasOnlyDefaultValues()

    /**
     * Hydrates (populates) the object variables with values from the database resultset.
     *
     * An offset (0-based "start column") is specified so that objects can be hydrated
     * with a subset of the columns in the resultset rows.  This is needed, for example,
     * for results of JOIN queries where the resultset row includes columns from two or
     * more tables.
     *
     * @param array   $row       The row returned by DataFetcher->fetch().
     * @param int     $startcol  0-based offset column which indicates which restultset column to start with.
     * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
     * @param string  $indexType The index type of $row. Mostly DataFetcher->getIndexType().
                                  One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
     *                            TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
     *
     * @return int             next starting column
     * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
     */
    public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
    {
        try {


            $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AmpSellerTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
            $this->id = (null !== $col) ? (int) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AmpSellerTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
            $this->ref = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AmpSellerTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
            $this->visible = (null !== $col) ? (int) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AmpSellerTableMap::translateFieldName('Address1', TableMap::TYPE_PHPNAME, $indexType)];
            $this->address1 = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AmpSellerTableMap::translateFieldName('Address2', TableMap::TYPE_PHPNAME, $indexType)];
            $this->address2 = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AmpSellerTableMap::translateFieldName('Address3', TableMap::TYPE_PHPNAME, $indexType)];
            $this->address3 = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AmpSellerTableMap::translateFieldName('Zipcode', TableMap::TYPE_PHPNAME, $indexType)];
            $this->zipcode = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AmpSellerTableMap::translateFieldName('City', TableMap::TYPE_PHPNAME, $indexType)];
            $this->city = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AmpSellerTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)];
            $this->country_id = (null !== $col) ? (int) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : AmpSellerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)];
            $this->email = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : AmpSellerTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)];
            $this->phone = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : AmpSellerTableMap::translateFieldName('Fax', TableMap::TYPE_PHPNAME, $indexType)];
            $this->fax = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : AmpSellerTableMap::translateFieldName('Url', TableMap::TYPE_PHPNAME, $indexType)];
            $this->url = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : AmpSellerTableMap::translateFieldName('Facebook', TableMap::TYPE_PHPNAME, $indexType)];
            $this->facebook = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : AmpSellerTableMap::translateFieldName('Twitter', TableMap::TYPE_PHPNAME, $indexType)];
            $this->twitter = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : AmpSellerTableMap::translateFieldName('Pinterest', TableMap::TYPE_PHPNAME, $indexType)];
            $this->pinterest = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : AmpSellerTableMap::translateFieldName('Google', TableMap::TYPE_PHPNAME, $indexType)];
            $this->google = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : AmpSellerTableMap::translateFieldName('Youtube', TableMap::TYPE_PHPNAME, $indexType)];
            $this->youtube = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 18 + $startcol : AmpSellerTableMap::translateFieldName('Instagram', TableMap::TYPE_PHPNAME, $indexType)];
            $this->instagram = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 19 + $startcol : AmpSellerTableMap::translateFieldName('Latitude', TableMap::TYPE_PHPNAME, $indexType)];
            $this->latitude = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 20 + $startcol : AmpSellerTableMap::translateFieldName('Longitude', TableMap::TYPE_PHPNAME, $indexType)];
            $this->longitude = (null !== $col) ? (string) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 21 + $startcol : AmpSellerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
            if ($col === '0000-00-00 00:00:00') {
                $col = null;
            }
            $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 22 + $startcol : AmpSellerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
            if ($col === '0000-00-00 00:00:00') {
                $col = null;
            }
            $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 23 + $startcol : AmpSellerTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
            $this->version = (null !== $col) ? (int) $col : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 24 + $startcol : AmpSellerTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
            if ($col === '0000-00-00 00:00:00') {
                $col = null;
            }
            $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;

            $col = $row[TableMap::TYPE_NUM == $indexType ? 25 + $startcol : AmpSellerTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
            $this->version_created_by = (null !== $col) ? (string) $col : null;
            $this->resetModified();

            $this->setNew(false);

            if ($rehydrate) {
                $this->ensureConsistency();
            }

            return $startcol + 26; // 26 = AmpSellerTableMap::NUM_HYDRATE_COLUMNS.

        } catch (Exception $e) {
            throw new PropelException("Error populating \ArtabanMarketplace\Model\AmpSeller object", 0, $e);
        }
    }

    /**
     * Checks and repairs the internal consistency of the object.
     *
     * This method is executed after an already-instantiated object is re-hydrated
     * from the database.  It exists to check any foreign keys to make sure that
     * the objects related to the current object are correct based on foreign key.
     *
     * You can override this method in the stub class, but you should always invoke
     * the base method from the overridden method (i.e. parent::ensureConsistency()),
     * in case your model changes.
     *
     * @throws PropelException
     */
    public function ensureConsistency()
    {
        if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) {
            $this->aCountry = null;
        }
    } // ensureConsistency

    /**
     * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
     *
     * This will only work if the object has been saved and has a valid primary key set.
     *
     * @param      boolean $deep (optional) Whether to also de-associated any related objects.
     * @param      ConnectionInterface $con (optional) The ConnectionInterface connection to use.
     * @return void
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
     */
    public function reload($deep = false, ConnectionInterface $con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("Cannot reload a deleted object.");
        }

        if ($this->isNew()) {
            throw new PropelException("Cannot reload an unsaved object.");
        }

        if ($con === null) {
            $con = Propel::getServiceContainer()->getReadConnection(AmpSellerTableMap::DATABASE_NAME);
        }

        // We don't need to alter the object instance pool; we're just modifying this instance
        // already in the pool.

        $dataFetcher = ChildAmpSellerQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
        $row = $dataFetcher->fetch();
        $dataFetcher->close();
        if (!$row) {
            throw new PropelException('Cannot find matching row in the database to reload object values.');
        }
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate

        if ($deep) {  // also de-associate any related objects?

            $this->aCountry = null;
            $this->collAmpSellerAdmins = null;

            $this->collAmpSellerProducts = null;

            $this->collAmpSellerImages = null;

            $this->collAmpSellerOrders = null;

            $this->collAmpSellerI18ns = null;

            $this->collAmpSellerVersions = null;

        } // if (deep)
    }

    /**
     * Removes this object from datastore and sets delete attribute.
     *
     * @param      ConnectionInterface $con
     * @return void
     * @throws PropelException
     * @see AmpSeller::setDeleted()
     * @see AmpSeller::isDeleted()
     */
    public function delete(ConnectionInterface $con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("This object has already been deleted.");
        }

        if ($con === null) {
            $con = Propel::getServiceContainer()->getWriteConnection(AmpSellerTableMap::DATABASE_NAME);
        }

        $con->beginTransaction();
        try {
            $deleteQuery = ChildAmpSellerQuery::create()
                ->filterByPrimaryKey($this->getPrimaryKey());
            $ret = $this->preDelete($con);
            if ($ret) {
                $deleteQuery->delete($con);
                $this->postDelete($con);
                $con->commit();
                $this->setDeleted(true);
            } else {
                $con->commit();
            }
        } catch (Exception $e) {
            $con->rollBack();
            throw $e;
        }
    }

    /**
     * Persists this object to the database.
     *
     * If the object is new, it inserts it; otherwise an update is performed.
     * All modified related objects will also be persisted in the doSave()
     * method.  This method wraps all precipitate database operations in a
     * single transaction.
     *
     * @param      ConnectionInterface $con
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     * @throws PropelException
     * @see doSave()
     */
    public function save(ConnectionInterface $con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("You cannot save an object that has been deleted.");
        }

        if ($con === null) {
            $con = Propel::getServiceContainer()->getWriteConnection(AmpSellerTableMap::DATABASE_NAME);
        }

        $con->beginTransaction();
        $isInsert = $this->isNew();
        try {
            $ret = $this->preSave($con);
            // versionable behavior
            if ($this->isVersioningNecessary()) {
                $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
                if (!$this->isColumnModified(AmpSellerTableMap::VERSION_CREATED_AT)) {
                    $this->setVersionCreatedAt(time());
                }
                $createVersion = true; // for postSave hook
            }
            if ($isInsert) {
                $ret = $ret && $this->preInsert($con);
                // timestampable behavior
                if (!$this->isColumnModified(AmpSellerTableMap::CREATED_AT)) {
                    $this->setCreatedAt(time());
                }
                if (!$this->isColumnModified(AmpSellerTableMap::UPDATED_AT)) {
                    $this->setUpdatedAt(time());
                }
            } else {
                $ret = $ret && $this->preUpdate($con);
                // timestampable behavior
                if ($this->isModified() && !$this->isColumnModified(AmpSellerTableMap::UPDATED_AT)) {
                    $this->setUpdatedAt(time());
                }
            }
            if ($ret) {
                $affectedRows = $this->doSave($con);
                if ($isInsert) {
                    $this->postInsert($con);
                } else {
                    $this->postUpdate($con);
                }
                $this->postSave($con);
                // versionable behavior
                if (isset($createVersion)) {
                    $this->addVersion($con);
                }
                AmpSellerTableMap::addInstanceToPool($this);
            } else {
                $affectedRows = 0;
            }
            $con->commit();

            return $affectedRows;
        } catch (Exception $e) {
            $con->rollBack();
            throw $e;
        }
    }

    /**
     * Performs the work of inserting or updating the row in the database.
     *
     * If the object is new, it inserts it; otherwise an update is performed.
     * All related objects are also updated in this method.
     *
     * @param      ConnectionInterface $con
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     * @throws PropelException
     * @see save()
     */
    protected function doSave(ConnectionInterface $con)
    {
        $affectedRows = 0; // initialize var to track total num of affected rows
        if (!$this->alreadyInSave) {
            $this->alreadyInSave = true;

            // We call the save method on the following object(s) if they
            // were passed to this object by their corresponding set
            // method.  This object relates to these object(s) by a
            // foreign key reference.

            if ($this->aCountry !== null) {
                if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
                    $affectedRows += $this->aCountry->save($con);
                }
                $this->setCountry($this->aCountry);
            }

            if ($this->isNew() || $this->isModified()) {
                // persist changes
                if ($this->isNew()) {
                    $this->doInsert($con);
                } else {
                    $this->doUpdate($con);
                }
                $affectedRows += 1;
                $this->resetModified();
            }

            if ($this->ampSellerAdminsScheduledForDeletion !== null) {
                if (!$this->ampSellerAdminsScheduledForDeletion->isEmpty()) {
                    \ArtabanMarketplace\Model\AmpSellerAdminQuery::create()
                        ->filterByPrimaryKeys($this->ampSellerAdminsScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->ampSellerAdminsScheduledForDeletion = null;
                }
            }

                if ($this->collAmpSellerAdmins !== null) {
            foreach ($this->collAmpSellerAdmins as $referrerFK) {
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->ampSellerProductsScheduledForDeletion !== null) {
                if (!$this->ampSellerProductsScheduledForDeletion->isEmpty()) {
                    \ArtabanMarketplace\Model\AmpSellerProductQuery::create()
                        ->filterByPrimaryKeys($this->ampSellerProductsScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->ampSellerProductsScheduledForDeletion = null;
                }
            }

                if ($this->collAmpSellerProducts !== null) {
            foreach ($this->collAmpSellerProducts as $referrerFK) {
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->ampSellerImagesScheduledForDeletion !== null) {
                if (!$this->ampSellerImagesScheduledForDeletion->isEmpty()) {
                    \ArtabanMarketplace\Model\AmpSellerImageQuery::create()
                        ->filterByPrimaryKeys($this->ampSellerImagesScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->ampSellerImagesScheduledForDeletion = null;
                }
            }

                if ($this->collAmpSellerImages !== null) {
            foreach ($this->collAmpSellerImages as $referrerFK) {
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->ampSellerOrdersScheduledForDeletion !== null) {
                if (!$this->ampSellerOrdersScheduledForDeletion->isEmpty()) {
                    \ArtabanMarketplace\Model\AmpSellerOrderQuery::create()
                        ->filterByPrimaryKeys($this->ampSellerOrdersScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->ampSellerOrdersScheduledForDeletion = null;
                }
            }

                if ($this->collAmpSellerOrders !== null) {
            foreach ($this->collAmpSellerOrders as $referrerFK) {
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->ampSellerI18nsScheduledForDeletion !== null) {
                if (!$this->ampSellerI18nsScheduledForDeletion->isEmpty()) {
                    \ArtabanMarketplace\Model\AmpSellerI18nQuery::create()
                        ->filterByPrimaryKeys($this->ampSellerI18nsScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->ampSellerI18nsScheduledForDeletion = null;
                }
            }

                if ($this->collAmpSellerI18ns !== null) {
            foreach ($this->collAmpSellerI18ns as $referrerFK) {
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->ampSellerVersionsScheduledForDeletion !== null) {
                if (!$this->ampSellerVersionsScheduledForDeletion->isEmpty()) {
                    \ArtabanMarketplace\Model\AmpSellerVersionQuery::create()
                        ->filterByPrimaryKeys($this->ampSellerVersionsScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->ampSellerVersionsScheduledForDeletion = null;
                }
            }

                if ($this->collAmpSellerVersions !== null) {
            foreach ($this->collAmpSellerVersions as $referrerFK) {
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            $this->alreadyInSave = false;

        }

        return $affectedRows;
    } // doSave()

    /**
     * Insert the row in the database.
     *
     * @param      ConnectionInterface $con
     *
     * @throws PropelException
     * @see doSave()
     */
    protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[AmpSellerTableMap::ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . AmpSellerTableMap::ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(AmpSellerTableMap::ID)) {
            $modifiedColumns[':p' . $index++]  = 'ID';
        }
        if ($this->isColumnModified(AmpSellerTableMap::REF)) {
            $modifiedColumns[':p' . $index++]  = 'REF';
        }
        if ($this->isColumnModified(AmpSellerTableMap::VISIBLE)) {
            $modifiedColumns[':p' . $index++]  = 'VISIBLE';
        }
        if ($this->isColumnModified(AmpSellerTableMap::ADDRESS1)) {
            $modifiedColumns[':p' . $index++]  = 'ADDRESS1';
        }
        if ($this->isColumnModified(AmpSellerTableMap::ADDRESS2)) {
            $modifiedColumns[':p' . $index++]  = 'ADDRESS2';
        }
        if ($this->isColumnModified(AmpSellerTableMap::ADDRESS3)) {
            $modifiedColumns[':p' . $index++]  = 'ADDRESS3';
        }
        if ($this->isColumnModified(AmpSellerTableMap::ZIPCODE)) {
            $modifiedColumns[':p' . $index++]  = 'ZIPCODE';
        }
        if ($this->isColumnModified(AmpSellerTableMap::CITY)) {
            $modifiedColumns[':p' . $index++]  = 'CITY';
        }
        if ($this->isColumnModified(AmpSellerTableMap::COUNTRY_ID)) {
            $modifiedColumns[':p' . $index++]  = 'COUNTRY_ID';
        }
        if ($this->isColumnModified(AmpSellerTableMap::EMAIL)) {
            $modifiedColumns[':p' . $index++]  = 'EMAIL';
        }
        if ($this->isColumnModified(AmpSellerTableMap::PHONE)) {
            $modifiedColumns[':p' . $index++]  = 'PHONE';
        }
        if ($this->isColumnModified(AmpSellerTableMap::FAX)) {
            $modifiedColumns[':p' . $index++]  = 'FAX';
        }
        if ($this->isColumnModified(AmpSellerTableMap::URL)) {
            $modifiedColumns[':p' . $index++]  = 'URL';
        }
        if ($this->isColumnModified(AmpSellerTableMap::FACEBOOK)) {
            $modifiedColumns[':p' . $index++]  = 'FACEBOOK';
        }
        if ($this->isColumnModified(AmpSellerTableMap::TWITTER)) {
            $modifiedColumns[':p' . $index++]  = 'TWITTER';
        }
        if ($this->isColumnModified(AmpSellerTableMap::PINTEREST)) {
            $modifiedColumns[':p' . $index++]  = 'PINTEREST';
        }
        if ($this->isColumnModified(AmpSellerTableMap::GOOGLE)) {
            $modifiedColumns[':p' . $index++]  = 'GOOGLE';
        }
        if ($this->isColumnModified(AmpSellerTableMap::YOUTUBE)) {
            $modifiedColumns[':p' . $index++]  = 'YOUTUBE';
        }
        if ($this->isColumnModified(AmpSellerTableMap::INSTAGRAM)) {
            $modifiedColumns[':p' . $index++]  = 'INSTAGRAM';
        }
        if ($this->isColumnModified(AmpSellerTableMap::LATITUDE)) {
            $modifiedColumns[':p' . $index++]  = 'LATITUDE';
        }
        if ($this->isColumnModified(AmpSellerTableMap::LONGITUDE)) {
            $modifiedColumns[':p' . $index++]  = 'LONGITUDE';
        }
        if ($this->isColumnModified(AmpSellerTableMap::CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'CREATED_AT';
        }
        if ($this->isColumnModified(AmpSellerTableMap::UPDATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'UPDATED_AT';
        }
        if ($this->isColumnModified(AmpSellerTableMap::VERSION)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION';
        }
        if ($this->isColumnModified(AmpSellerTableMap::VERSION_CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_AT';
        }
        if ($this->isColumnModified(AmpSellerTableMap::VERSION_CREATED_BY)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_BY';
        }

        $sql = sprintf(
            'INSERT INTO amp_seller (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'ID':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'REF':
                        $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
                        break;
                    case 'VISIBLE':
                        $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
                        break;
                    case 'ADDRESS1':
                        $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR);
                        break;
                    case 'ADDRESS2':
                        $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR);
                        break;
                    case 'ADDRESS3':
                        $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR);
                        break;
                    case 'ZIPCODE':
                        $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR);
                        break;
                    case 'CITY':
                        $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
                        break;
                    case 'COUNTRY_ID':
                        $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
                        break;
                    case 'EMAIL':
                        $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR);
                        break;
                    case 'PHONE':
                        $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
                        break;
                    case 'FAX':
                        $stmt->bindValue($identifier, $this->fax, PDO::PARAM_STR);
                        break;
                    case 'URL':
                        $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
                        break;
                    case 'FACEBOOK':
                        $stmt->bindValue($identifier, $this->facebook, PDO::PARAM_STR);
                        break;
                    case 'TWITTER':
                        $stmt->bindValue($identifier, $this->twitter, PDO::PARAM_STR);
                        break;
                    case 'PINTEREST':
                        $stmt->bindValue($identifier, $this->pinterest, PDO::PARAM_STR);
                        break;
                    case 'GOOGLE':
                        $stmt->bindValue($identifier, $this->google, PDO::PARAM_STR);
                        break;
                    case 'YOUTUBE':
                        $stmt->bindValue($identifier, $this->youtube, PDO::PARAM_STR);
                        break;
                    case 'INSTAGRAM':
                        $stmt->bindValue($identifier, $this->instagram, PDO::PARAM_STR);
                        break;
                    case 'LATITUDE':
                        $stmt->bindValue($identifier, $this->latitude, PDO::PARAM_STR);
                        break;
                    case 'LONGITUDE':
                        $stmt->bindValue($identifier, $this->longitude, PDO::PARAM_STR);
                        break;
                    case 'CREATED_AT':
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'UPDATED_AT':
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION':
                        $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
                        break;
                    case 'VERSION_CREATED_AT':
                        $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION_CREATED_BY':
                        $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }

    /**
     * Update the row in the database.
     *
     * @param      ConnectionInterface $con
     *
     * @return Integer Number of updated rows
     * @see doSave()
     */
    protected function doUpdate(ConnectionInterface $con)
    {
        $selectCriteria = $this->buildPkeyCriteria();
        $valuesCriteria = $this->buildCriteria();

        return $selectCriteria->doUpdate($valuesCriteria, $con);
    }

    /**
     * Retrieves a field from the object by name passed in as a string.
     *
     * @param      string $name name
     * @param      string $type The type of fieldname the $name is of:
     *                     one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
     *                     TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
     *                     Defaults to TableMap::TYPE_PHPNAME.
     * @return mixed Value of field.
     */
    public function getByName($name, $type = TableMap::TYPE_PHPNAME)
    {
        $pos = AmpSellerTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
        $field = $this->getByPosition($pos);

        return $field;
    }

    /**
     * Retrieves a field from the object by Position as specified in the xml schema.
     * Zero-based.
     *
     * @param      int $pos position in xml schema
     * @return mixed Value of field at $pos
     */
    public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getRef();
                break;
            case 2:
                return $this->getVisible();
                break;
            case 3:
                return $this->getAddress1();
                break;
            case 4:
                return $this->getAddress2();
                break;
            case 5:
                return $this->getAddress3();
                break;
            case 6:
                return $this->getZipcode();
                break;
            case 7:
                return $this->getCity();
                break;
            case 8:
                return $this->getCountryId();
                break;
            case 9:
                return $this->getEmail();
                break;
            case 10:
                return $this->getPhone();
                break;
            case 11:
                return $this->getFax();
                break;
            case 12:
                return $this->getUrl();
                break;
            case 13:
                return $this->getFacebook();
                break;
            case 14:
                return $this->getTwitter();
                break;
            case 15:
                return $this->getPinterest();
                break;
            case 16:
                return $this->getGoogle();
                break;
            case 17:
                return $this->getYoutube();
                break;
            case 18:
                return $this->getInstagram();
                break;
            case 19:
                return $this->getLatitude();
                break;
            case 20:
                return $this->getLongitude();
                break;
            case 21:
                return $this->getCreatedAt();
                break;
            case 22:
                return $this->getUpdatedAt();
                break;
            case 23:
                return $this->getVersion();
                break;
            case 24:
                return $this->getVersionCreatedAt();
                break;
            case 25:
                return $this->getVersionCreatedBy();
                break;
            default:
                return null;
                break;
        } // switch()
    }

    /**
     * Exports the object as an array.
     *
     * You can specify the key type of the array by passing one of the class
     * type constants.
     *
     * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
     *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
     *                    Defaults to TableMap::TYPE_PHPNAME.
     * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
     * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
     * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
     *
     * @return array an associative array containing the field names (as keys) and field values
     */
    public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
    {
        if (isset($alreadyDumpedObjects['AmpSeller'][$this->getPrimaryKey()])) {
            return '*RECURSION*';
        }
        $alreadyDumpedObjects['AmpSeller'][$this->getPrimaryKey()] = true;
        $keys = AmpSellerTableMap::getFieldNames($keyType);
        $result = array(
            $keys[0] => $this->getId(),
            $keys[1] => $this->getRef(),
            $keys[2] => $this->getVisible(),
            $keys[3] => $this->getAddress1(),
            $keys[4] => $this->getAddress2(),
            $keys[5] => $this->getAddress3(),
            $keys[6] => $this->getZipcode(),
            $keys[7] => $this->getCity(),
            $keys[8] => $this->getCountryId(),
            $keys[9] => $this->getEmail(),
            $keys[10] => $this->getPhone(),
            $keys[11] => $this->getFax(),
            $keys[12] => $this->getUrl(),
            $keys[13] => $this->getFacebook(),
            $keys[14] => $this->getTwitter(),
            $keys[15] => $this->getPinterest(),
            $keys[16] => $this->getGoogle(),
            $keys[17] => $this->getYoutube(),
            $keys[18] => $this->getInstagram(),
            $keys[19] => $this->getLatitude(),
            $keys[20] => $this->getLongitude(),
            $keys[21] => $this->getCreatedAt(),
            $keys[22] => $this->getUpdatedAt(),
            $keys[23] => $this->getVersion(),
            $keys[24] => $this->getVersionCreatedAt(),
            $keys[25] => $this->getVersionCreatedBy(),
        );
        $virtualColumns = $this->virtualColumns;
        foreach ($virtualColumns as $key => $virtualColumn) {
            $result[$key] = $virtualColumn;
        }

        if ($includeForeignObjects) {
            if (null !== $this->aCountry) {
                $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->collAmpSellerAdmins) {
                $result['AmpSellerAdmins'] = $this->collAmpSellerAdmins->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collAmpSellerProducts) {
                $result['AmpSellerProducts'] = $this->collAmpSellerProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collAmpSellerImages) {
                $result['AmpSellerImages'] = $this->collAmpSellerImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collAmpSellerOrders) {
                $result['AmpSellerOrders'] = $this->collAmpSellerOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collAmpSellerI18ns) {
                $result['AmpSellerI18ns'] = $this->collAmpSellerI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collAmpSellerVersions) {
                $result['AmpSellerVersions'] = $this->collAmpSellerVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
        }

        return $result;
    }

    /**
     * Sets a field from the object by name passed in as a string.
     *
     * @param      string $name
     * @param      mixed  $value field value
     * @param      string $type The type of fieldname the $name is of:
     *                     one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
     *                     TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
     *                     Defaults to TableMap::TYPE_PHPNAME.
     * @return void
     */
    public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
    {
        $pos = AmpSellerTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);

        return $this->setByPosition($pos, $value);
    }

    /**
     * Sets a field from the object by Position as specified in the xml schema.
     * Zero-based.
     *
     * @param      int $pos position in xml schema
     * @param      mixed $value field value
     * @return void
     */
    public function setByPosition($pos, $value)
    {
        switch ($pos) {
            case 0:
                $this->setId($value);
                break;
            case 1:
                $this->setRef($value);
                break;
            case 2:
                $this->setVisible($value);
                break;
            case 3:
                $this->setAddress1($value);
                break;
            case 4:
                $this->setAddress2($value);
                break;
            case 5:
                $this->setAddress3($value);
                break;
            case 6:
                $this->setZipcode($value);
                break;
            case 7:
                $this->setCity($value);
                break;
            case 8:
                $this->setCountryId($value);
                break;
            case 9:
                $this->setEmail($value);
                break;
            case 10:
                $this->setPhone($value);
                break;
            case 11:
                $this->setFax($value);
                break;
            case 12:
                $this->setUrl($value);
                break;
            case 13:
                $this->setFacebook($value);
                break;
            case 14:
                $this->setTwitter($value);
                break;
            case 15:
                $this->setPinterest($value);
                break;
            case 16:
                $this->setGoogle($value);
                break;
            case 17:
                $this->setYoutube($value);
                break;
            case 18:
                $this->setInstagram($value);
                break;
            case 19:
                $this->setLatitude($value);
                break;
            case 20:
                $this->setLongitude($value);
                break;
            case 21:
                $this->setCreatedAt($value);
                break;
            case 22:
                $this->setUpdatedAt($value);
                break;
            case 23:
                $this->setVersion($value);
                break;
            case 24:
                $this->setVersionCreatedAt($value);
                break;
            case 25:
                $this->setVersionCreatedBy($value);
                break;
        } // switch()
    }

    /**
     * Populates the object using an array.
     *
     * This is particularly useful when populating an object from one of the
     * request arrays (e.g. $_POST).  This method goes through the column
     * names, checking to see whether a matching key exists in populated
     * array. If so the setByName() method is called for that column.
     *
     * You can specify the key type of the array by additionally passing one
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
     * The default key type is the column's TableMap::TYPE_PHPNAME.
     *
     * @param      array  $arr     An array to populate the object from.
     * @param      string $keyType The type of keys the array uses.
     * @return void
     */
    public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
    {
        $keys = AmpSellerTableMap::getFieldNames($keyType);

        if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
        if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]);
        if (array_key_exists($keys[2], $arr)) $this->setVisible($arr[$keys[2]]);
        if (array_key_exists($keys[3], $arr)) $this->setAddress1($arr[$keys[3]]);
        if (array_key_exists($keys[4], $arr)) $this->setAddress2($arr[$keys[4]]);
        if (array_key_exists($keys[5], $arr)) $this->setAddress3($arr[$keys[5]]);
        if (array_key_exists($keys[6], $arr)) $this->setZipcode($arr[$keys[6]]);
        if (array_key_exists($keys[7], $arr)) $this->setCity($arr[$keys[7]]);
        if (array_key_exists($keys[8], $arr)) $this->setCountryId($arr[$keys[8]]);
        if (array_key_exists($keys[9], $arr)) $this->setEmail($arr[$keys[9]]);
        if (array_key_exists($keys[10], $arr)) $this->setPhone($arr[$keys[10]]);
        if (array_key_exists($keys[11], $arr)) $this->setFax($arr[$keys[11]]);
        if (array_key_exists($keys[12], $arr)) $this->setUrl($arr[$keys[12]]);
        if (array_key_exists($keys[13], $arr)) $this->setFacebook($arr[$keys[13]]);
        if (array_key_exists($keys[14], $arr)) $this->setTwitter($arr[$keys[14]]);
        if (array_key_exists($keys[15], $arr)) $this->setPinterest($arr[$keys[15]]);
        if (array_key_exists($keys[16], $arr)) $this->setGoogle($arr[$keys[16]]);
        if (array_key_exists($keys[17], $arr)) $this->setYoutube($arr[$keys[17]]);
        if (array_key_exists($keys[18], $arr)) $this->setInstagram($arr[$keys[18]]);
        if (array_key_exists($keys[19], $arr)) $this->setLatitude($arr[$keys[19]]);
        if (array_key_exists($keys[20], $arr)) $this->setLongitude($arr[$keys[20]]);
        if (array_key_exists($keys[21], $arr)) $this->setCreatedAt($arr[$keys[21]]);
        if (array_key_exists($keys[22], $arr)) $this->setUpdatedAt($arr[$keys[22]]);
        if (array_key_exists($keys[23], $arr)) $this->setVersion($arr[$keys[23]]);
        if (array_key_exists($keys[24], $arr)) $this->setVersionCreatedAt($arr[$keys[24]]);
        if (array_key_exists($keys[25], $arr)) $this->setVersionCreatedBy($arr[$keys[25]]);
    }

    /**
     * Build a Criteria object containing the values of all modified columns in this object.
     *
     * @return Criteria The Criteria object containing all modified values.
     */
    public function buildCriteria()
    {
        $criteria = new Criteria(AmpSellerTableMap::DATABASE_NAME);

        if ($this->isColumnModified(AmpSellerTableMap::ID)) $criteria->add(AmpSellerTableMap::ID, $this->id);
        if ($this->isColumnModified(AmpSellerTableMap::REF)) $criteria->add(AmpSellerTableMap::REF, $this->ref);
        if ($this->isColumnModified(AmpSellerTableMap::VISIBLE)) $criteria->add(AmpSellerTableMap::VISIBLE, $this->visible);
        if ($this->isColumnModified(AmpSellerTableMap::ADDRESS1)) $criteria->add(AmpSellerTableMap::ADDRESS1, $this->address1);
        if ($this->isColumnModified(AmpSellerTableMap::ADDRESS2)) $criteria->add(AmpSellerTableMap::ADDRESS2, $this->address2);
        if ($this->isColumnModified(AmpSellerTableMap::ADDRESS3)) $criteria->add(AmpSellerTableMap::ADDRESS3, $this->address3);
        if ($this->isColumnModified(AmpSellerTableMap::ZIPCODE)) $criteria->add(AmpSellerTableMap::ZIPCODE, $this->zipcode);
        if ($this->isColumnModified(AmpSellerTableMap::CITY)) $criteria->add(AmpSellerTableMap::CITY, $this->city);
        if ($this->isColumnModified(AmpSellerTableMap::COUNTRY_ID)) $criteria->add(AmpSellerTableMap::COUNTRY_ID, $this->country_id);
        if ($this->isColumnModified(AmpSellerTableMap::EMAIL)) $criteria->add(AmpSellerTableMap::EMAIL, $this->email);
        if ($this->isColumnModified(AmpSellerTableMap::PHONE)) $criteria->add(AmpSellerTableMap::PHONE, $this->phone);
        if ($this->isColumnModified(AmpSellerTableMap::FAX)) $criteria->add(AmpSellerTableMap::FAX, $this->fax);
        if ($this->isColumnModified(AmpSellerTableMap::URL)) $criteria->add(AmpSellerTableMap::URL, $this->url);
        if ($this->isColumnModified(AmpSellerTableMap::FACEBOOK)) $criteria->add(AmpSellerTableMap::FACEBOOK, $this->facebook);
        if ($this->isColumnModified(AmpSellerTableMap::TWITTER)) $criteria->add(AmpSellerTableMap::TWITTER, $this->twitter);
        if ($this->isColumnModified(AmpSellerTableMap::PINTEREST)) $criteria->add(AmpSellerTableMap::PINTEREST, $this->pinterest);
        if ($this->isColumnModified(AmpSellerTableMap::GOOGLE)) $criteria->add(AmpSellerTableMap::GOOGLE, $this->google);
        if ($this->isColumnModified(AmpSellerTableMap::YOUTUBE)) $criteria->add(AmpSellerTableMap::YOUTUBE, $this->youtube);
        if ($this->isColumnModified(AmpSellerTableMap::INSTAGRAM)) $criteria->add(AmpSellerTableMap::INSTAGRAM, $this->instagram);
        if ($this->isColumnModified(AmpSellerTableMap::LATITUDE)) $criteria->add(AmpSellerTableMap::LATITUDE, $this->latitude);
        if ($this->isColumnModified(AmpSellerTableMap::LONGITUDE)) $criteria->add(AmpSellerTableMap::LONGITUDE, $this->longitude);
        if ($this->isColumnModified(AmpSellerTableMap::CREATED_AT)) $criteria->add(AmpSellerTableMap::CREATED_AT, $this->created_at);
        if ($this->isColumnModified(AmpSellerTableMap::UPDATED_AT)) $criteria->add(AmpSellerTableMap::UPDATED_AT, $this->updated_at);
        if ($this->isColumnModified(AmpSellerTableMap::VERSION)) $criteria->add(AmpSellerTableMap::VERSION, $this->version);
        if ($this->isColumnModified(AmpSellerTableMap::VERSION_CREATED_AT)) $criteria->add(AmpSellerTableMap::VERSION_CREATED_AT, $this->version_created_at);
        if ($this->isColumnModified(AmpSellerTableMap::VERSION_CREATED_BY)) $criteria->add(AmpSellerTableMap::VERSION_CREATED_BY, $this->version_created_by);

        return $criteria;
    }

    /**
     * Builds a Criteria object containing the primary key for this object.
     *
     * Unlike buildCriteria() this method includes the primary key values regardless
     * of whether or not they have been modified.
     *
     * @return Criteria The Criteria object containing value(s) for primary key(s).
     */
    public function buildPkeyCriteria()
    {
        $criteria = new Criteria(AmpSellerTableMap::DATABASE_NAME);
        $criteria->add(AmpSellerTableMap::ID, $this->id);

        return $criteria;
    }

    /**
     * Returns the primary key for this object (row).
     * @return   int
     */
    public function getPrimaryKey()
    {
        return $this->getId();
    }

    /**
     * Generic method to set the primary key (id column).
     *
     * @param       int $key Primary key.
     * @return void
     */
    public function setPrimaryKey($key)
    {
        $this->setId($key);
    }

    /**
     * Returns true if the primary key for this object is null.
     * @return boolean
     */
    public function isPrimaryKeyNull()
    {

        return null === $this->getId();
    }

    /**
     * Sets contents of passed object to values from current object.
     *
     * If desired, this method can also make copies of all associated (fkey referrers)
     * objects.
     *
     * @param      object $copyObj An object of \ArtabanMarketplace\Model\AmpSeller (or compatible) type.
     * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     * @param      boolean $makeNew Whether to reset autoincrement PKs and make the object new.
     * @throws PropelException
     */
    public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
    {
        $copyObj->setRef($this->getRef());
        $copyObj->setVisible($this->getVisible());
        $copyObj->setAddress1($this->getAddress1());
        $copyObj->setAddress2($this->getAddress2());
        $copyObj->setAddress3($this->getAddress3());
        $copyObj->setZipcode($this->getZipcode());
        $copyObj->setCity($this->getCity());
        $copyObj->setCountryId($this->getCountryId());
        $copyObj->setEmail($this->getEmail());
        $copyObj->setPhone($this->getPhone());
        $copyObj->setFax($this->getFax());
        $copyObj->setUrl($this->getUrl());
        $copyObj->setFacebook($this->getFacebook());
        $copyObj->setTwitter($this->getTwitter());
        $copyObj->setPinterest($this->getPinterest());
        $copyObj->setGoogle($this->getGoogle());
        $copyObj->setYoutube($this->getYoutube());
        $copyObj->setInstagram($this->getInstagram());
        $copyObj->setLatitude($this->getLatitude());
        $copyObj->setLongitude($this->getLongitude());
        $copyObj->setCreatedAt($this->getCreatedAt());
        $copyObj->setUpdatedAt($this->getUpdatedAt());
        $copyObj->setVersion($this->getVersion());
        $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
        $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());

        if ($deepCopy) {
            // important: temporarily setNew(false) because this affects the behavior of
            // the getter/setter methods for fkey referrer objects.
            $copyObj->setNew(false);

            foreach ($this->getAmpSellerAdmins() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addAmpSellerAdmin($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getAmpSellerProducts() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addAmpSellerProduct($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getAmpSellerImages() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addAmpSellerImage($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getAmpSellerOrders() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addAmpSellerOrder($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getAmpSellerI18ns() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addAmpSellerI18n($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getAmpSellerVersions() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addAmpSellerVersion($relObj->copy($deepCopy));
                }
            }

        } // if ($deepCopy)

        if ($makeNew) {
            $copyObj->setNew(true);
            $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
        }
    }

    /**
     * Makes a copy of this object that will be inserted as a new row in table when saved.
     * It creates a new object filling in the simple attributes, but skipping any primary
     * keys that are defined for the table.
     *
     * If desired, this method can also make copies of all associated (fkey referrers)
     * objects.
     *
     * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     * @return                 \ArtabanMarketplace\Model\AmpSeller Clone of current object.
     * @throws PropelException
     */
    public function copy($deepCopy = false)
    {
        // we use get_class(), because this might be a subclass
        $clazz = get_class($this);
        $copyObj = new $clazz();
        $this->copyInto($copyObj, $deepCopy);

        return $copyObj;
    }

    /**
     * Declares an association between this object and a ChildCountry object.
     *
     * @param                  ChildCountry $v
     * @return                 \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     * @throws PropelException
     */
    public function setCountry(ChildCountry $v = null)
    {
        if ($v === null) {
            $this->setCountryId(NULL);
        } else {
            $this->setCountryId($v->getId());
        }

        $this->aCountry = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildCountry object, it will not be re-added.
        if ($v !== null) {
            $v->addAmpSeller($this);
        }


        return $this;
    }


    /**
     * Get the associated ChildCountry object
     *
     * @param      ConnectionInterface $con Optional Connection object.
     * @return                 ChildCountry The associated ChildCountry object.
     * @throws PropelException
     */
    public function getCountry(ConnectionInterface $con = null)
    {
        if ($this->aCountry === null && ($this->country_id !== null)) {
            $this->aCountry = CountryQuery::create()->findPk($this->country_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aCountry->addAmpSellers($this);
             */
        }

        return $this->aCountry;
    }


    /**
     * Initializes a collection based on the name of a relation.
     * Avoids crafting an 'init[$relationName]s' method name
     * that wouldn't work when StandardEnglishPluralizer is used.
     *
     * @param      string $relationName The name of the relation to initialize
     * @return void
     */
    public function initRelation($relationName)
    {
        if ('AmpSellerAdmin' == $relationName) {
            return $this->initAmpSellerAdmins();
        }
        if ('AmpSellerProduct' == $relationName) {
            return $this->initAmpSellerProducts();
        }
        if ('AmpSellerImage' == $relationName) {
            return $this->initAmpSellerImages();
        }
        if ('AmpSellerOrder' == $relationName) {
            return $this->initAmpSellerOrders();
        }
        if ('AmpSellerI18n' == $relationName) {
            return $this->initAmpSellerI18ns();
        }
        if ('AmpSellerVersion' == $relationName) {
            return $this->initAmpSellerVersions();
        }
    }

    /**
     * Clears out the collAmpSellerAdmins collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addAmpSellerAdmins()
     */
    public function clearAmpSellerAdmins()
    {
        $this->collAmpSellerAdmins = null; // important to set this to NULL since that means it is uninitialized
    }

    /**
     * Reset is the collAmpSellerAdmins collection loaded partially.
     */
    public function resetPartialAmpSellerAdmins($v = true)
    {
        $this->collAmpSellerAdminsPartial = $v;
    }

    /**
     * Initializes the collAmpSellerAdmins collection.
     *
     * By default this just sets the collAmpSellerAdmins collection to an empty array (like clearcollAmpSellerAdmins());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param      boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initAmpSellerAdmins($overrideExisting = true)
    {
        if (null !== $this->collAmpSellerAdmins && !$overrideExisting) {
            return;
        }
        $this->collAmpSellerAdmins = new ObjectCollection();
        $this->collAmpSellerAdmins->setModel('\ArtabanMarketplace\Model\AmpSellerAdmin');
    }

    /**
     * Gets an array of ChildAmpSellerAdmin objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this ChildAmpSeller is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @return Collection|ChildAmpSellerAdmin[] List of ChildAmpSellerAdmin objects
     * @throws PropelException
     */
    public function getAmpSellerAdmins($criteria = null, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerAdminsPartial && !$this->isNew();
        if (null === $this->collAmpSellerAdmins || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerAdmins) {
                // return empty collection
                $this->initAmpSellerAdmins();
            } else {
                $collAmpSellerAdmins = ChildAmpSellerAdminQuery::create(null, $criteria)
                    ->filterByAmpSeller($this)
                    ->find($con);

                if (null !== $criteria) {
                    if (false !== $this->collAmpSellerAdminsPartial && count($collAmpSellerAdmins)) {
                        $this->initAmpSellerAdmins(false);

                        foreach ($collAmpSellerAdmins as $obj) {
                            if (false == $this->collAmpSellerAdmins->contains($obj)) {
                                $this->collAmpSellerAdmins->append($obj);
                            }
                        }

                        $this->collAmpSellerAdminsPartial = true;
                    }

                    reset($collAmpSellerAdmins);

                    return $collAmpSellerAdmins;
                }

                if ($partial && $this->collAmpSellerAdmins) {
                    foreach ($this->collAmpSellerAdmins as $obj) {
                        if ($obj->isNew()) {
                            $collAmpSellerAdmins[] = $obj;
                        }
                    }
                }

                $this->collAmpSellerAdmins = $collAmpSellerAdmins;
                $this->collAmpSellerAdminsPartial = false;
            }
        }

        return $this->collAmpSellerAdmins;
    }

    /**
     * Sets a collection of AmpSellerAdmin objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param      Collection $ampSellerAdmins A Propel collection.
     * @param      ConnectionInterface $con Optional connection object
     * @return   ChildAmpSeller The current object (for fluent API support)
     */
    public function setAmpSellerAdmins(Collection $ampSellerAdmins, ConnectionInterface $con = null)
    {
        $ampSellerAdminsToDelete = $this->getAmpSellerAdmins(new Criteria(), $con)->diff($ampSellerAdmins);


        $this->ampSellerAdminsScheduledForDeletion = $ampSellerAdminsToDelete;

        foreach ($ampSellerAdminsToDelete as $ampSellerAdminRemoved) {
            $ampSellerAdminRemoved->setAmpSeller(null);
        }

        $this->collAmpSellerAdmins = null;
        foreach ($ampSellerAdmins as $ampSellerAdmin) {
            $this->addAmpSellerAdmin($ampSellerAdmin);
        }

        $this->collAmpSellerAdmins = $ampSellerAdmins;
        $this->collAmpSellerAdminsPartial = false;

        return $this;
    }

    /**
     * Returns the number of related AmpSellerAdmin objects.
     *
     * @param      Criteria $criteria
     * @param      boolean $distinct
     * @param      ConnectionInterface $con
     * @return int             Count of related AmpSellerAdmin objects.
     * @throws PropelException
     */
    public function countAmpSellerAdmins(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerAdminsPartial && !$this->isNew();
        if (null === $this->collAmpSellerAdmins || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerAdmins) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getAmpSellerAdmins());
            }

            $query = ChildAmpSellerAdminQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByAmpSeller($this)
                ->count($con);
        }

        return count($this->collAmpSellerAdmins);
    }

    /**
     * Method called to associate a ChildAmpSellerAdmin object to this object
     * through the ChildAmpSellerAdmin foreign key attribute.
     *
     * @param    ChildAmpSellerAdmin $l ChildAmpSellerAdmin
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function addAmpSellerAdmin(ChildAmpSellerAdmin $l)
    {
        if ($this->collAmpSellerAdmins === null) {
            $this->initAmpSellerAdmins();
            $this->collAmpSellerAdminsPartial = true;
        }

        if (!in_array($l, $this->collAmpSellerAdmins->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
            $this->doAddAmpSellerAdmin($l);
        }

        return $this;
    }

    /**
     * @param AmpSellerAdmin $ampSellerAdmin The ampSellerAdmin object to add.
     */
    protected function doAddAmpSellerAdmin($ampSellerAdmin)
    {
        $this->collAmpSellerAdmins[]= $ampSellerAdmin;
        $ampSellerAdmin->setAmpSeller($this);
    }

    /**
     * @param  AmpSellerAdmin $ampSellerAdmin The ampSellerAdmin object to remove.
     * @return ChildAmpSeller The current object (for fluent API support)
     */
    public function removeAmpSellerAdmin($ampSellerAdmin)
    {
        if ($this->getAmpSellerAdmins()->contains($ampSellerAdmin)) {
            $this->collAmpSellerAdmins->remove($this->collAmpSellerAdmins->search($ampSellerAdmin));
            if (null === $this->ampSellerAdminsScheduledForDeletion) {
                $this->ampSellerAdminsScheduledForDeletion = clone $this->collAmpSellerAdmins;
                $this->ampSellerAdminsScheduledForDeletion->clear();
            }
            $this->ampSellerAdminsScheduledForDeletion[]= clone $ampSellerAdmin;
            $ampSellerAdmin->setAmpSeller(null);
        }

        return $this;
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this AmpSeller is new, it will return
     * an empty collection; or if this AmpSeller has previously
     * been saved, it will retrieve related AmpSellerAdmins from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in AmpSeller.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return Collection|ChildAmpSellerAdmin[] List of ChildAmpSellerAdmin objects
     */
    public function getAmpSellerAdminsJoinAdmin($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
    {
        $query = ChildAmpSellerAdminQuery::create(null, $criteria);
        $query->joinWith('Admin', $joinBehavior);

        return $this->getAmpSellerAdmins($query, $con);
    }

    /**
     * Clears out the collAmpSellerProducts collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addAmpSellerProducts()
     */
    public function clearAmpSellerProducts()
    {
        $this->collAmpSellerProducts = null; // important to set this to NULL since that means it is uninitialized
    }

    /**
     * Reset is the collAmpSellerProducts collection loaded partially.
     */
    public function resetPartialAmpSellerProducts($v = true)
    {
        $this->collAmpSellerProductsPartial = $v;
    }

    /**
     * Initializes the collAmpSellerProducts collection.
     *
     * By default this just sets the collAmpSellerProducts collection to an empty array (like clearcollAmpSellerProducts());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param      boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initAmpSellerProducts($overrideExisting = true)
    {
        if (null !== $this->collAmpSellerProducts && !$overrideExisting) {
            return;
        }
        $this->collAmpSellerProducts = new ObjectCollection();
        $this->collAmpSellerProducts->setModel('\ArtabanMarketplace\Model\AmpSellerProduct');
    }

    /**
     * Gets an array of ChildAmpSellerProduct objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this ChildAmpSeller is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @return Collection|ChildAmpSellerProduct[] List of ChildAmpSellerProduct objects
     * @throws PropelException
     */
    public function getAmpSellerProducts($criteria = null, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerProductsPartial && !$this->isNew();
        if (null === $this->collAmpSellerProducts || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerProducts) {
                // return empty collection
                $this->initAmpSellerProducts();
            } else {
                $collAmpSellerProducts = ChildAmpSellerProductQuery::create(null, $criteria)
                    ->filterByAmpSeller($this)
                    ->find($con);

                if (null !== $criteria) {
                    if (false !== $this->collAmpSellerProductsPartial && count($collAmpSellerProducts)) {
                        $this->initAmpSellerProducts(false);

                        foreach ($collAmpSellerProducts as $obj) {
                            if (false == $this->collAmpSellerProducts->contains($obj)) {
                                $this->collAmpSellerProducts->append($obj);
                            }
                        }

                        $this->collAmpSellerProductsPartial = true;
                    }

                    reset($collAmpSellerProducts);

                    return $collAmpSellerProducts;
                }

                if ($partial && $this->collAmpSellerProducts) {
                    foreach ($this->collAmpSellerProducts as $obj) {
                        if ($obj->isNew()) {
                            $collAmpSellerProducts[] = $obj;
                        }
                    }
                }

                $this->collAmpSellerProducts = $collAmpSellerProducts;
                $this->collAmpSellerProductsPartial = false;
            }
        }

        return $this->collAmpSellerProducts;
    }

    /**
     * Sets a collection of AmpSellerProduct objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param      Collection $ampSellerProducts A Propel collection.
     * @param      ConnectionInterface $con Optional connection object
     * @return   ChildAmpSeller The current object (for fluent API support)
     */
    public function setAmpSellerProducts(Collection $ampSellerProducts, ConnectionInterface $con = null)
    {
        $ampSellerProductsToDelete = $this->getAmpSellerProducts(new Criteria(), $con)->diff($ampSellerProducts);


        $this->ampSellerProductsScheduledForDeletion = $ampSellerProductsToDelete;

        foreach ($ampSellerProductsToDelete as $ampSellerProductRemoved) {
            $ampSellerProductRemoved->setAmpSeller(null);
        }

        $this->collAmpSellerProducts = null;
        foreach ($ampSellerProducts as $ampSellerProduct) {
            $this->addAmpSellerProduct($ampSellerProduct);
        }

        $this->collAmpSellerProducts = $ampSellerProducts;
        $this->collAmpSellerProductsPartial = false;

        return $this;
    }

    /**
     * Returns the number of related AmpSellerProduct objects.
     *
     * @param      Criteria $criteria
     * @param      boolean $distinct
     * @param      ConnectionInterface $con
     * @return int             Count of related AmpSellerProduct objects.
     * @throws PropelException
     */
    public function countAmpSellerProducts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerProductsPartial && !$this->isNew();
        if (null === $this->collAmpSellerProducts || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerProducts) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getAmpSellerProducts());
            }

            $query = ChildAmpSellerProductQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByAmpSeller($this)
                ->count($con);
        }

        return count($this->collAmpSellerProducts);
    }

    /**
     * Method called to associate a ChildAmpSellerProduct object to this object
     * through the ChildAmpSellerProduct foreign key attribute.
     *
     * @param    ChildAmpSellerProduct $l ChildAmpSellerProduct
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function addAmpSellerProduct(ChildAmpSellerProduct $l)
    {
        if ($this->collAmpSellerProducts === null) {
            $this->initAmpSellerProducts();
            $this->collAmpSellerProductsPartial = true;
        }

        if (!in_array($l, $this->collAmpSellerProducts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
            $this->doAddAmpSellerProduct($l);
        }

        return $this;
    }

    /**
     * @param AmpSellerProduct $ampSellerProduct The ampSellerProduct object to add.
     */
    protected function doAddAmpSellerProduct($ampSellerProduct)
    {
        $this->collAmpSellerProducts[]= $ampSellerProduct;
        $ampSellerProduct->setAmpSeller($this);
    }

    /**
     * @param  AmpSellerProduct $ampSellerProduct The ampSellerProduct object to remove.
     * @return ChildAmpSeller The current object (for fluent API support)
     */
    public function removeAmpSellerProduct($ampSellerProduct)
    {
        if ($this->getAmpSellerProducts()->contains($ampSellerProduct)) {
            $this->collAmpSellerProducts->remove($this->collAmpSellerProducts->search($ampSellerProduct));
            if (null === $this->ampSellerProductsScheduledForDeletion) {
                $this->ampSellerProductsScheduledForDeletion = clone $this->collAmpSellerProducts;
                $this->ampSellerProductsScheduledForDeletion->clear();
            }
            $this->ampSellerProductsScheduledForDeletion[]= clone $ampSellerProduct;
            $ampSellerProduct->setAmpSeller(null);
        }

        return $this;
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this AmpSeller is new, it will return
     * an empty collection; or if this AmpSeller has previously
     * been saved, it will retrieve related AmpSellerProducts from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in AmpSeller.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return Collection|ChildAmpSellerProduct[] List of ChildAmpSellerProduct objects
     */
    public function getAmpSellerProductsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
    {
        $query = ChildAmpSellerProductQuery::create(null, $criteria);
        $query->joinWith('Product', $joinBehavior);

        return $this->getAmpSellerProducts($query, $con);
    }

    /**
     * Clears out the collAmpSellerImages collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addAmpSellerImages()
     */
    public function clearAmpSellerImages()
    {
        $this->collAmpSellerImages = null; // important to set this to NULL since that means it is uninitialized
    }

    /**
     * Reset is the collAmpSellerImages collection loaded partially.
     */
    public function resetPartialAmpSellerImages($v = true)
    {
        $this->collAmpSellerImagesPartial = $v;
    }

    /**
     * Initializes the collAmpSellerImages collection.
     *
     * By default this just sets the collAmpSellerImages collection to an empty array (like clearcollAmpSellerImages());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param      boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initAmpSellerImages($overrideExisting = true)
    {
        if (null !== $this->collAmpSellerImages && !$overrideExisting) {
            return;
        }
        $this->collAmpSellerImages = new ObjectCollection();
        $this->collAmpSellerImages->setModel('\ArtabanMarketplace\Model\AmpSellerImage');
    }

    /**
     * Gets an array of ChildAmpSellerImage objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this ChildAmpSeller is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @return Collection|ChildAmpSellerImage[] List of ChildAmpSellerImage objects
     * @throws PropelException
     */
    public function getAmpSellerImages($criteria = null, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerImagesPartial && !$this->isNew();
        if (null === $this->collAmpSellerImages || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerImages) {
                // return empty collection
                $this->initAmpSellerImages();
            } else {
                $collAmpSellerImages = ChildAmpSellerImageQuery::create(null, $criteria)
                    ->filterByAmpSeller($this)
                    ->find($con);

                if (null !== $criteria) {
                    if (false !== $this->collAmpSellerImagesPartial && count($collAmpSellerImages)) {
                        $this->initAmpSellerImages(false);

                        foreach ($collAmpSellerImages as $obj) {
                            if (false == $this->collAmpSellerImages->contains($obj)) {
                                $this->collAmpSellerImages->append($obj);
                            }
                        }

                        $this->collAmpSellerImagesPartial = true;
                    }

                    reset($collAmpSellerImages);

                    return $collAmpSellerImages;
                }

                if ($partial && $this->collAmpSellerImages) {
                    foreach ($this->collAmpSellerImages as $obj) {
                        if ($obj->isNew()) {
                            $collAmpSellerImages[] = $obj;
                        }
                    }
                }

                $this->collAmpSellerImages = $collAmpSellerImages;
                $this->collAmpSellerImagesPartial = false;
            }
        }

        return $this->collAmpSellerImages;
    }

    /**
     * Sets a collection of AmpSellerImage objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param      Collection $ampSellerImages A Propel collection.
     * @param      ConnectionInterface $con Optional connection object
     * @return   ChildAmpSeller The current object (for fluent API support)
     */
    public function setAmpSellerImages(Collection $ampSellerImages, ConnectionInterface $con = null)
    {
        $ampSellerImagesToDelete = $this->getAmpSellerImages(new Criteria(), $con)->diff($ampSellerImages);


        $this->ampSellerImagesScheduledForDeletion = $ampSellerImagesToDelete;

        foreach ($ampSellerImagesToDelete as $ampSellerImageRemoved) {
            $ampSellerImageRemoved->setAmpSeller(null);
        }

        $this->collAmpSellerImages = null;
        foreach ($ampSellerImages as $ampSellerImage) {
            $this->addAmpSellerImage($ampSellerImage);
        }

        $this->collAmpSellerImages = $ampSellerImages;
        $this->collAmpSellerImagesPartial = false;

        return $this;
    }

    /**
     * Returns the number of related AmpSellerImage objects.
     *
     * @param      Criteria $criteria
     * @param      boolean $distinct
     * @param      ConnectionInterface $con
     * @return int             Count of related AmpSellerImage objects.
     * @throws PropelException
     */
    public function countAmpSellerImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerImagesPartial && !$this->isNew();
        if (null === $this->collAmpSellerImages || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerImages) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getAmpSellerImages());
            }

            $query = ChildAmpSellerImageQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByAmpSeller($this)
                ->count($con);
        }

        return count($this->collAmpSellerImages);
    }

    /**
     * Method called to associate a ChildAmpSellerImage object to this object
     * through the ChildAmpSellerImage foreign key attribute.
     *
     * @param    ChildAmpSellerImage $l ChildAmpSellerImage
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function addAmpSellerImage(ChildAmpSellerImage $l)
    {
        if ($this->collAmpSellerImages === null) {
            $this->initAmpSellerImages();
            $this->collAmpSellerImagesPartial = true;
        }

        if (!in_array($l, $this->collAmpSellerImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
            $this->doAddAmpSellerImage($l);
        }

        return $this;
    }

    /**
     * @param AmpSellerImage $ampSellerImage The ampSellerImage object to add.
     */
    protected function doAddAmpSellerImage($ampSellerImage)
    {
        $this->collAmpSellerImages[]= $ampSellerImage;
        $ampSellerImage->setAmpSeller($this);
    }

    /**
     * @param  AmpSellerImage $ampSellerImage The ampSellerImage object to remove.
     * @return ChildAmpSeller The current object (for fluent API support)
     */
    public function removeAmpSellerImage($ampSellerImage)
    {
        if ($this->getAmpSellerImages()->contains($ampSellerImage)) {
            $this->collAmpSellerImages->remove($this->collAmpSellerImages->search($ampSellerImage));
            if (null === $this->ampSellerImagesScheduledForDeletion) {
                $this->ampSellerImagesScheduledForDeletion = clone $this->collAmpSellerImages;
                $this->ampSellerImagesScheduledForDeletion->clear();
            }
            $this->ampSellerImagesScheduledForDeletion[]= clone $ampSellerImage;
            $ampSellerImage->setAmpSeller(null);
        }

        return $this;
    }

    /**
     * Clears out the collAmpSellerOrders collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addAmpSellerOrders()
     */
    public function clearAmpSellerOrders()
    {
        $this->collAmpSellerOrders = null; // important to set this to NULL since that means it is uninitialized
    }

    /**
     * Reset is the collAmpSellerOrders collection loaded partially.
     */
    public function resetPartialAmpSellerOrders($v = true)
    {
        $this->collAmpSellerOrdersPartial = $v;
    }

    /**
     * Initializes the collAmpSellerOrders collection.
     *
     * By default this just sets the collAmpSellerOrders collection to an empty array (like clearcollAmpSellerOrders());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param      boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initAmpSellerOrders($overrideExisting = true)
    {
        if (null !== $this->collAmpSellerOrders && !$overrideExisting) {
            return;
        }
        $this->collAmpSellerOrders = new ObjectCollection();
        $this->collAmpSellerOrders->setModel('\ArtabanMarketplace\Model\AmpSellerOrder');
    }

    /**
     * Gets an array of ChildAmpSellerOrder objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this ChildAmpSeller is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @return Collection|ChildAmpSellerOrder[] List of ChildAmpSellerOrder objects
     * @throws PropelException
     */
    public function getAmpSellerOrders($criteria = null, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerOrdersPartial && !$this->isNew();
        if (null === $this->collAmpSellerOrders || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerOrders) {
                // return empty collection
                $this->initAmpSellerOrders();
            } else {
                $collAmpSellerOrders = ChildAmpSellerOrderQuery::create(null, $criteria)
                    ->filterByAmpSeller($this)
                    ->find($con);

                if (null !== $criteria) {
                    if (false !== $this->collAmpSellerOrdersPartial && count($collAmpSellerOrders)) {
                        $this->initAmpSellerOrders(false);

                        foreach ($collAmpSellerOrders as $obj) {
                            if (false == $this->collAmpSellerOrders->contains($obj)) {
                                $this->collAmpSellerOrders->append($obj);
                            }
                        }

                        $this->collAmpSellerOrdersPartial = true;
                    }

                    reset($collAmpSellerOrders);

                    return $collAmpSellerOrders;
                }

                if ($partial && $this->collAmpSellerOrders) {
                    foreach ($this->collAmpSellerOrders as $obj) {
                        if ($obj->isNew()) {
                            $collAmpSellerOrders[] = $obj;
                        }
                    }
                }

                $this->collAmpSellerOrders = $collAmpSellerOrders;
                $this->collAmpSellerOrdersPartial = false;
            }
        }

        return $this->collAmpSellerOrders;
    }

    /**
     * Sets a collection of AmpSellerOrder objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param      Collection $ampSellerOrders A Propel collection.
     * @param      ConnectionInterface $con Optional connection object
     * @return   ChildAmpSeller The current object (for fluent API support)
     */
    public function setAmpSellerOrders(Collection $ampSellerOrders, ConnectionInterface $con = null)
    {
        $ampSellerOrdersToDelete = $this->getAmpSellerOrders(new Criteria(), $con)->diff($ampSellerOrders);


        $this->ampSellerOrdersScheduledForDeletion = $ampSellerOrdersToDelete;

        foreach ($ampSellerOrdersToDelete as $ampSellerOrderRemoved) {
            $ampSellerOrderRemoved->setAmpSeller(null);
        }

        $this->collAmpSellerOrders = null;
        foreach ($ampSellerOrders as $ampSellerOrder) {
            $this->addAmpSellerOrder($ampSellerOrder);
        }

        $this->collAmpSellerOrders = $ampSellerOrders;
        $this->collAmpSellerOrdersPartial = false;

        return $this;
    }

    /**
     * Returns the number of related AmpSellerOrder objects.
     *
     * @param      Criteria $criteria
     * @param      boolean $distinct
     * @param      ConnectionInterface $con
     * @return int             Count of related AmpSellerOrder objects.
     * @throws PropelException
     */
    public function countAmpSellerOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerOrdersPartial && !$this->isNew();
        if (null === $this->collAmpSellerOrders || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerOrders) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getAmpSellerOrders());
            }

            $query = ChildAmpSellerOrderQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByAmpSeller($this)
                ->count($con);
        }

        return count($this->collAmpSellerOrders);
    }

    /**
     * Method called to associate a ChildAmpSellerOrder object to this object
     * through the ChildAmpSellerOrder foreign key attribute.
     *
     * @param    ChildAmpSellerOrder $l ChildAmpSellerOrder
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function addAmpSellerOrder(ChildAmpSellerOrder $l)
    {
        if ($this->collAmpSellerOrders === null) {
            $this->initAmpSellerOrders();
            $this->collAmpSellerOrdersPartial = true;
        }

        if (!in_array($l, $this->collAmpSellerOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
            $this->doAddAmpSellerOrder($l);
        }

        return $this;
    }

    /**
     * @param AmpSellerOrder $ampSellerOrder The ampSellerOrder object to add.
     */
    protected function doAddAmpSellerOrder($ampSellerOrder)
    {
        $this->collAmpSellerOrders[]= $ampSellerOrder;
        $ampSellerOrder->setAmpSeller($this);
    }

    /**
     * @param  AmpSellerOrder $ampSellerOrder The ampSellerOrder object to remove.
     * @return ChildAmpSeller The current object (for fluent API support)
     */
    public function removeAmpSellerOrder($ampSellerOrder)
    {
        if ($this->getAmpSellerOrders()->contains($ampSellerOrder)) {
            $this->collAmpSellerOrders->remove($this->collAmpSellerOrders->search($ampSellerOrder));
            if (null === $this->ampSellerOrdersScheduledForDeletion) {
                $this->ampSellerOrdersScheduledForDeletion = clone $this->collAmpSellerOrders;
                $this->ampSellerOrdersScheduledForDeletion->clear();
            }
            $this->ampSellerOrdersScheduledForDeletion[]= clone $ampSellerOrder;
            $ampSellerOrder->setAmpSeller(null);
        }

        return $this;
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this AmpSeller is new, it will return
     * an empty collection; or if this AmpSeller has previously
     * been saved, it will retrieve related AmpSellerOrders from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in AmpSeller.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return Collection|ChildAmpSellerOrder[] List of ChildAmpSellerOrder objects
     */
    public function getAmpSellerOrdersJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
    {
        $query = ChildAmpSellerOrderQuery::create(null, $criteria);
        $query->joinWith('Customer', $joinBehavior);

        return $this->getAmpSellerOrders($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this AmpSeller is new, it will return
     * an empty collection; or if this AmpSeller has previously
     * been saved, it will retrieve related AmpSellerOrders from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in AmpSeller.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return Collection|ChildAmpSellerOrder[] List of ChildAmpSellerOrder objects
     */
    public function getAmpSellerOrdersJoinAmpSellerOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
    {
        $query = ChildAmpSellerOrderQuery::create(null, $criteria);
        $query->joinWith('AmpSellerOrderStatus', $joinBehavior);

        return $this->getAmpSellerOrders($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this AmpSeller is new, it will return
     * an empty collection; or if this AmpSeller has previously
     * been saved, it will retrieve related AmpSellerOrders from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in AmpSeller.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return Collection|ChildAmpSellerOrder[] List of ChildAmpSellerOrder objects
     */
    public function getAmpSellerOrdersJoinOrder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
    {
        $query = ChildAmpSellerOrderQuery::create(null, $criteria);
        $query->joinWith('Order', $joinBehavior);

        return $this->getAmpSellerOrders($query, $con);
    }

    /**
     * Clears out the collAmpSellerI18ns collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addAmpSellerI18ns()
     */
    public function clearAmpSellerI18ns()
    {
        $this->collAmpSellerI18ns = null; // important to set this to NULL since that means it is uninitialized
    }

    /**
     * Reset is the collAmpSellerI18ns collection loaded partially.
     */
    public function resetPartialAmpSellerI18ns($v = true)
    {
        $this->collAmpSellerI18nsPartial = $v;
    }

    /**
     * Initializes the collAmpSellerI18ns collection.
     *
     * By default this just sets the collAmpSellerI18ns collection to an empty array (like clearcollAmpSellerI18ns());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param      boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initAmpSellerI18ns($overrideExisting = true)
    {
        if (null !== $this->collAmpSellerI18ns && !$overrideExisting) {
            return;
        }
        $this->collAmpSellerI18ns = new ObjectCollection();
        $this->collAmpSellerI18ns->setModel('\ArtabanMarketplace\Model\AmpSellerI18n');
    }

    /**
     * Gets an array of ChildAmpSellerI18n objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this ChildAmpSeller is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @return Collection|ChildAmpSellerI18n[] List of ChildAmpSellerI18n objects
     * @throws PropelException
     */
    public function getAmpSellerI18ns($criteria = null, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerI18nsPartial && !$this->isNew();
        if (null === $this->collAmpSellerI18ns || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerI18ns) {
                // return empty collection
                $this->initAmpSellerI18ns();
            } else {
                $collAmpSellerI18ns = ChildAmpSellerI18nQuery::create(null, $criteria)
                    ->filterByAmpSeller($this)
                    ->find($con);

                if (null !== $criteria) {
                    if (false !== $this->collAmpSellerI18nsPartial && count($collAmpSellerI18ns)) {
                        $this->initAmpSellerI18ns(false);

                        foreach ($collAmpSellerI18ns as $obj) {
                            if (false == $this->collAmpSellerI18ns->contains($obj)) {
                                $this->collAmpSellerI18ns->append($obj);
                            }
                        }

                        $this->collAmpSellerI18nsPartial = true;
                    }

                    reset($collAmpSellerI18ns);

                    return $collAmpSellerI18ns;
                }

                if ($partial && $this->collAmpSellerI18ns) {
                    foreach ($this->collAmpSellerI18ns as $obj) {
                        if ($obj->isNew()) {
                            $collAmpSellerI18ns[] = $obj;
                        }
                    }
                }

                $this->collAmpSellerI18ns = $collAmpSellerI18ns;
                $this->collAmpSellerI18nsPartial = false;
            }
        }

        return $this->collAmpSellerI18ns;
    }

    /**
     * Sets a collection of AmpSellerI18n objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param      Collection $ampSellerI18ns A Propel collection.
     * @param      ConnectionInterface $con Optional connection object
     * @return   ChildAmpSeller The current object (for fluent API support)
     */
    public function setAmpSellerI18ns(Collection $ampSellerI18ns, ConnectionInterface $con = null)
    {
        $ampSellerI18nsToDelete = $this->getAmpSellerI18ns(new Criteria(), $con)->diff($ampSellerI18ns);


        //since at least one column in the foreign key is at the same time a PK
        //we can not just set a PK to NULL in the lines below. We have to store
        //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
        $this->ampSellerI18nsScheduledForDeletion = clone $ampSellerI18nsToDelete;

        foreach ($ampSellerI18nsToDelete as $ampSellerI18nRemoved) {
            $ampSellerI18nRemoved->setAmpSeller(null);
        }

        $this->collAmpSellerI18ns = null;
        foreach ($ampSellerI18ns as $ampSellerI18n) {
            $this->addAmpSellerI18n($ampSellerI18n);
        }

        $this->collAmpSellerI18ns = $ampSellerI18ns;
        $this->collAmpSellerI18nsPartial = false;

        return $this;
    }

    /**
     * Returns the number of related AmpSellerI18n objects.
     *
     * @param      Criteria $criteria
     * @param      boolean $distinct
     * @param      ConnectionInterface $con
     * @return int             Count of related AmpSellerI18n objects.
     * @throws PropelException
     */
    public function countAmpSellerI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerI18nsPartial && !$this->isNew();
        if (null === $this->collAmpSellerI18ns || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerI18ns) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getAmpSellerI18ns());
            }

            $query = ChildAmpSellerI18nQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByAmpSeller($this)
                ->count($con);
        }

        return count($this->collAmpSellerI18ns);
    }

    /**
     * Method called to associate a ChildAmpSellerI18n object to this object
     * through the ChildAmpSellerI18n foreign key attribute.
     *
     * @param    ChildAmpSellerI18n $l ChildAmpSellerI18n
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function addAmpSellerI18n(ChildAmpSellerI18n $l)
    {
        if ($l && $locale = $l->getLocale()) {
            $this->setLocale($locale);
            $this->currentTranslations[$locale] = $l;
        }
        if ($this->collAmpSellerI18ns === null) {
            $this->initAmpSellerI18ns();
            $this->collAmpSellerI18nsPartial = true;
        }

        if (!in_array($l, $this->collAmpSellerI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
            $this->doAddAmpSellerI18n($l);
        }

        return $this;
    }

    /**
     * @param AmpSellerI18n $ampSellerI18n The ampSellerI18n object to add.
     */
    protected function doAddAmpSellerI18n($ampSellerI18n)
    {
        $this->collAmpSellerI18ns[]= $ampSellerI18n;
        $ampSellerI18n->setAmpSeller($this);
    }

    /**
     * @param  AmpSellerI18n $ampSellerI18n The ampSellerI18n object to remove.
     * @return ChildAmpSeller The current object (for fluent API support)
     */
    public function removeAmpSellerI18n($ampSellerI18n)
    {
        if ($this->getAmpSellerI18ns()->contains($ampSellerI18n)) {
            $this->collAmpSellerI18ns->remove($this->collAmpSellerI18ns->search($ampSellerI18n));
            if (null === $this->ampSellerI18nsScheduledForDeletion) {
                $this->ampSellerI18nsScheduledForDeletion = clone $this->collAmpSellerI18ns;
                $this->ampSellerI18nsScheduledForDeletion->clear();
            }
            $this->ampSellerI18nsScheduledForDeletion[]= clone $ampSellerI18n;
            $ampSellerI18n->setAmpSeller(null);
        }

        return $this;
    }

    /**
     * Clears out the collAmpSellerVersions collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addAmpSellerVersions()
     */
    public function clearAmpSellerVersions()
    {
        $this->collAmpSellerVersions = null; // important to set this to NULL since that means it is uninitialized
    }

    /**
     * Reset is the collAmpSellerVersions collection loaded partially.
     */
    public function resetPartialAmpSellerVersions($v = true)
    {
        $this->collAmpSellerVersionsPartial = $v;
    }

    /**
     * Initializes the collAmpSellerVersions collection.
     *
     * By default this just sets the collAmpSellerVersions collection to an empty array (like clearcollAmpSellerVersions());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param      boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initAmpSellerVersions($overrideExisting = true)
    {
        if (null !== $this->collAmpSellerVersions && !$overrideExisting) {
            return;
        }
        $this->collAmpSellerVersions = new ObjectCollection();
        $this->collAmpSellerVersions->setModel('\ArtabanMarketplace\Model\AmpSellerVersion');
    }

    /**
     * Gets an array of ChildAmpSellerVersion objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this ChildAmpSeller is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param      Criteria $criteria optional Criteria object to narrow the query
     * @param      ConnectionInterface $con optional connection object
     * @return Collection|ChildAmpSellerVersion[] List of ChildAmpSellerVersion objects
     * @throws PropelException
     */
    public function getAmpSellerVersions($criteria = null, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerVersionsPartial && !$this->isNew();
        if (null === $this->collAmpSellerVersions || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerVersions) {
                // return empty collection
                $this->initAmpSellerVersions();
            } else {
                $collAmpSellerVersions = ChildAmpSellerVersionQuery::create(null, $criteria)
                    ->filterByAmpSeller($this)
                    ->find($con);

                if (null !== $criteria) {
                    if (false !== $this->collAmpSellerVersionsPartial && count($collAmpSellerVersions)) {
                        $this->initAmpSellerVersions(false);

                        foreach ($collAmpSellerVersions as $obj) {
                            if (false == $this->collAmpSellerVersions->contains($obj)) {
                                $this->collAmpSellerVersions->append($obj);
                            }
                        }

                        $this->collAmpSellerVersionsPartial = true;
                    }

                    reset($collAmpSellerVersions);

                    return $collAmpSellerVersions;
                }

                if ($partial && $this->collAmpSellerVersions) {
                    foreach ($this->collAmpSellerVersions as $obj) {
                        if ($obj->isNew()) {
                            $collAmpSellerVersions[] = $obj;
                        }
                    }
                }

                $this->collAmpSellerVersions = $collAmpSellerVersions;
                $this->collAmpSellerVersionsPartial = false;
            }
        }

        return $this->collAmpSellerVersions;
    }

    /**
     * Sets a collection of AmpSellerVersion objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param      Collection $ampSellerVersions A Propel collection.
     * @param      ConnectionInterface $con Optional connection object
     * @return   ChildAmpSeller The current object (for fluent API support)
     */
    public function setAmpSellerVersions(Collection $ampSellerVersions, ConnectionInterface $con = null)
    {
        $ampSellerVersionsToDelete = $this->getAmpSellerVersions(new Criteria(), $con)->diff($ampSellerVersions);


        //since at least one column in the foreign key is at the same time a PK
        //we can not just set a PK to NULL in the lines below. We have to store
        //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
        $this->ampSellerVersionsScheduledForDeletion = clone $ampSellerVersionsToDelete;

        foreach ($ampSellerVersionsToDelete as $ampSellerVersionRemoved) {
            $ampSellerVersionRemoved->setAmpSeller(null);
        }

        $this->collAmpSellerVersions = null;
        foreach ($ampSellerVersions as $ampSellerVersion) {
            $this->addAmpSellerVersion($ampSellerVersion);
        }

        $this->collAmpSellerVersions = $ampSellerVersions;
        $this->collAmpSellerVersionsPartial = false;

        return $this;
    }

    /**
     * Returns the number of related AmpSellerVersion objects.
     *
     * @param      Criteria $criteria
     * @param      boolean $distinct
     * @param      ConnectionInterface $con
     * @return int             Count of related AmpSellerVersion objects.
     * @throws PropelException
     */
    public function countAmpSellerVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collAmpSellerVersionsPartial && !$this->isNew();
        if (null === $this->collAmpSellerVersions || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collAmpSellerVersions) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getAmpSellerVersions());
            }

            $query = ChildAmpSellerVersionQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByAmpSeller($this)
                ->count($con);
        }

        return count($this->collAmpSellerVersions);
    }

    /**
     * Method called to associate a ChildAmpSellerVersion object to this object
     * through the ChildAmpSellerVersion foreign key attribute.
     *
     * @param    ChildAmpSellerVersion $l ChildAmpSellerVersion
     * @return   \ArtabanMarketplace\Model\AmpSeller The current object (for fluent API support)
     */
    public function addAmpSellerVersion(ChildAmpSellerVersion $l)
    {
        if ($this->collAmpSellerVersions === null) {
            $this->initAmpSellerVersions();
            $this->collAmpSellerVersionsPartial = true;
        }

        if (!in_array($l, $this->collAmpSellerVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
            $this->doAddAmpSellerVersion($l);
        }

        return $this;
    }

    /**
     * @param AmpSellerVersion $ampSellerVersion The ampSellerVersion object to add.
     */
    protected function doAddAmpSellerVersion($ampSellerVersion)
    {
        $this->collAmpSellerVersions[]= $ampSellerVersion;
        $ampSellerVersion->setAmpSeller($this);
    }

    /**
     * @param  AmpSellerVersion $ampSellerVersion The ampSellerVersion object to remove.
     * @return ChildAmpSeller The current object (for fluent API support)
     */
    public function removeAmpSellerVersion($ampSellerVersion)
    {
        if ($this->getAmpSellerVersions()->contains($ampSellerVersion)) {
            $this->collAmpSellerVersions->remove($this->collAmpSellerVersions->search($ampSellerVersion));
            if (null === $this->ampSellerVersionsScheduledForDeletion) {
                $this->ampSellerVersionsScheduledForDeletion = clone $this->collAmpSellerVersions;
                $this->ampSellerVersionsScheduledForDeletion->clear();
            }
            $this->ampSellerVersionsScheduledForDeletion[]= clone $ampSellerVersion;
            $ampSellerVersion->setAmpSeller(null);
        }

        return $this;
    }

    /**
     * Clears the current object and sets all attributes to their default values
     */
    public function clear()
    {
        $this->id = null;
        $this->ref = null;
        $this->visible = null;
        $this->address1 = null;
        $this->address2 = null;
        $this->address3 = null;
        $this->zipcode = null;
        $this->city = null;
        $this->country_id = null;
        $this->email = null;
        $this->phone = null;
        $this->fax = null;
        $this->url = null;
        $this->facebook = null;
        $this->twitter = null;
        $this->pinterest = null;
        $this->google = null;
        $this->youtube = null;
        $this->instagram = null;
        $this->latitude = null;
        $this->longitude = null;
        $this->created_at = null;
        $this->updated_at = null;
        $this->version = null;
        $this->version_created_at = null;
        $this->version_created_by = null;
        $this->alreadyInSave = false;
        $this->clearAllReferences();
        $this->applyDefaultValues();
        $this->resetModified();
        $this->setNew(true);
        $this->setDeleted(false);
    }

    /**
     * Resets all references to other model objects or collections of model objects.
     *
     * This method is a user-space workaround for PHP's inability to garbage collect
     * objects with circular references (even in PHP 5.3). This is currently necessary
     * when using Propel in certain daemon or large-volume/high-memory operations.
     *
     * @param      boolean $deep Whether to also clear the references on all referrer objects.
     */
    public function clearAllReferences($deep = false)
    {
        if ($deep) {
            if ($this->collAmpSellerAdmins) {
                foreach ($this->collAmpSellerAdmins as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collAmpSellerProducts) {
                foreach ($this->collAmpSellerProducts as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collAmpSellerImages) {
                foreach ($this->collAmpSellerImages as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collAmpSellerOrders) {
                foreach ($this->collAmpSellerOrders as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collAmpSellerI18ns) {
                foreach ($this->collAmpSellerI18ns as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collAmpSellerVersions) {
                foreach ($this->collAmpSellerVersions as $o) {
                    $o->clearAllReferences($deep);
                }
            }
        } // if ($deep)

        // i18n behavior
        $this->currentLocale = 'en_US';
        $this->currentTranslations = null;

        $this->collAmpSellerAdmins = null;
        $this->collAmpSellerProducts = null;
        $this->collAmpSellerImages = null;
        $this->collAmpSellerOrders = null;
        $this->collAmpSellerI18ns = null;
        $this->collAmpSellerVersions = null;
        $this->aCountry = null;
    }

    /**
     * Return the string representation of this object
     *
     * @return string
     */
    public function __toString()
    {
        return (string) $this->exportTo(AmpSellerTableMap::DEFAULT_STRING_FORMAT);
    }

    // timestampable behavior

    /**
     * Mark the current object so that the update date doesn't get updated during next save
     *
     * @return     ChildAmpSeller The current object (for fluent API support)
     */
    public function keepUpdateDateUnchanged()
    {
        $this->modifiedColumns[AmpSellerTableMap::UPDATED_AT] = true;

        return $this;
    }

    // i18n behavior

    /**
     * Sets the locale for translations
     *
     * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
     *
     * @return    ChildAmpSeller The current object (for fluent API support)
     */
    public function setLocale($locale = 'en_US')
    {
        $this->currentLocale = $locale;

        return $this;
    }

    /**
     * Gets the locale for translations
     *
     * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
     */
    public function getLocale()
    {
        return $this->currentLocale;
    }

    /**
     * Returns the current translation for a given locale
     *
     * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
     * @param     ConnectionInterface $con an optional connection object
     *
     * @return ChildAmpSellerI18n */
    public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
    {
        if (!isset($this->currentTranslations[$locale])) {
            if (null !== $this->collAmpSellerI18ns) {
                foreach ($this->collAmpSellerI18ns as $translation) {
                    if ($translation->getLocale() == $locale) {
                        $this->currentTranslations[$locale] = $translation;

                        return $translation;
                    }
                }
            }
            if ($this->isNew()) {
                $translation = new ChildAmpSellerI18n();
                $translation->setLocale($locale);
            } else {
                $translation = ChildAmpSellerI18nQuery::create()
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
                    ->findOneOrCreate($con);
                $this->currentTranslations[$locale] = $translation;
            }
            $this->addAmpSellerI18n($translation);
        }

        return $this->currentTranslations[$locale];
    }

    /**
     * Remove the translation for a given locale
     *
     * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
     * @param     ConnectionInterface $con an optional connection object
     *
     * @return    ChildAmpSeller The current object (for fluent API support)
     */
    public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null)
    {
        if (!$this->isNew()) {
            ChildAmpSellerI18nQuery::create()
                ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
                ->delete($con);
        }
        if (isset($this->currentTranslations[$locale])) {
            unset($this->currentTranslations[$locale]);
        }
        foreach ($this->collAmpSellerI18ns as $key => $translation) {
            if ($translation->getLocale() == $locale) {
                unset($this->collAmpSellerI18ns[$key]);
                break;
            }
        }

        return $this;
    }

    /**
     * Returns the current translation
     *
     * @param     ConnectionInterface $con an optional connection object
     *
     * @return ChildAmpSellerI18n */
    public function getCurrentTranslation(ConnectionInterface $con = null)
    {
        return $this->getTranslation($this->getLocale(), $con);
    }


        /**
         * Get the [title] column value.
         *
         * @return   string
         */
        public function getTitle()
        {
        return $this->getCurrentTranslation()->getTitle();
    }


        /**
         * Set the value of [title] column.
         *
         * @param      string $v new value
         * @return   \ArtabanMarketplace\Model\AmpSellerI18n The current object (for fluent API support)
         */
        public function setTitle($v)
        {    $this->getCurrentTranslation()->setTitle($v);

        return $this;
    }


        /**
         * Get the [description] column value.
         *
         * @return   string
         */
        public function getDescription()
        {
        return $this->getCurrentTranslation()->getDescription();
    }


        /**
         * Set the value of [description] column.
         *
         * @param      string $v new value
         * @return   \ArtabanMarketplace\Model\AmpSellerI18n The current object (for fluent API support)
         */
        public function setDescription($v)
        {    $this->getCurrentTranslation()->setDescription($v);

        return $this;
    }


        /**
         * Get the [access] column value.
         *
         * @return   string
         */
        public function getAccess()
        {
        return $this->getCurrentTranslation()->getAccess();
    }


        /**
         * Set the value of [access] column.
         *
         * @param      string $v new value
         * @return   \ArtabanMarketplace\Model\AmpSellerI18n The current object (for fluent API support)
         */
        public function setAccess($v)
        {    $this->getCurrentTranslation()->setAccess($v);

        return $this;
    }

    // versionable behavior

    /**
     * Enforce a new Version of this object upon next save.
     *
     * @return \ArtabanMarketplace\Model\AmpSeller
     */
    public function enforceVersioning()
    {
        $this->enforceVersion = true;

        return $this;
    }

    /**
     * Checks whether the current state must be recorded as a version
     *
     * @return  boolean
     */
    public function isVersioningNecessary($con = null)
    {
        if ($this->alreadyInSave) {
            return false;
        }

        if ($this->enforceVersion) {
            return true;
        }

        if (ChildAmpSellerQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
            return true;
        }
        // to avoid infinite loops, emulate in save
        $this->alreadyInSave = true;
        foreach ($this->getAmpSellerAdmins(null, $con) as $relatedObject) {
            if ($relatedObject->isVersioningNecessary($con)) {
                $this->alreadyInSave = false;

                return true;
            }
        }
        $this->alreadyInSave = false;

        // to avoid infinite loops, emulate in save
        $this->alreadyInSave = true;
        foreach ($this->getAmpSellerProducts(null, $con) as $relatedObject) {
            if ($relatedObject->isVersioningNecessary($con)) {
                $this->alreadyInSave = false;

                return true;
            }
        }
        $this->alreadyInSave = false;

        // to avoid infinite loops, emulate in save
        $this->alreadyInSave = true;
        foreach ($this->getAmpSellerOrders(null, $con) as $relatedObject) {
            if ($relatedObject->isVersioningNecessary($con)) {
                $this->alreadyInSave = false;

                return true;
            }
        }
        $this->alreadyInSave = false;


        return false;
    }

    /**
     * Creates a version of the current object and saves it.
     *
     * @param   ConnectionInterface $con the connection to use
     *
     * @return  ChildAmpSellerVersion A version object
     */
    public function addVersion($con = null)
    {
        $this->enforceVersion = false;

        $version = new ChildAmpSellerVersion();
        $version->setId($this->getId());
        $version->setRef($this->getRef());
        $version->setVisible($this->getVisible());
        $version->setAddress1($this->getAddress1());
        $version->setAddress2($this->getAddress2());
        $version->setAddress3($this->getAddress3());
        $version->setZipcode($this->getZipcode());
        $version->setCity($this->getCity());
        $version->setCountryId($this->getCountryId());
        $version->setEmail($this->getEmail());
        $version->setPhone($this->getPhone());
        $version->setFax($this->getFax());
        $version->setUrl($this->getUrl());
        $version->setFacebook($this->getFacebook());
        $version->setTwitter($this->getTwitter());
        $version->setPinterest($this->getPinterest());
        $version->setGoogle($this->getGoogle());
        $version->setYoutube($this->getYoutube());
        $version->setInstagram($this->getInstagram());
        $version->setLatitude($this->getLatitude());
        $version->setLongitude($this->getLongitude());
        $version->setCreatedAt($this->getCreatedAt());
        $version->setUpdatedAt($this->getUpdatedAt());
        $version->setVersion($this->getVersion());
        $version->setVersionCreatedAt($this->getVersionCreatedAt());
        $version->setVersionCreatedBy($this->getVersionCreatedBy());
        $version->setAmpSeller($this);
        if ($relateds = $this->getAmpSellerAdmins($con)->toKeyValue('Id', 'Version')) {
            $version->setAmpSellerAdminIds(array_keys($relateds));
            $version->setAmpSellerAdminVersions(array_values($relateds));
        }
        if ($relateds = $this->getAmpSellerProducts($con)->toKeyValue('Id', 'Version')) {
            $version->setAmpSellerProductIds(array_keys($relateds));
            $version->setAmpSellerProductVersions(array_values($relateds));
        }
        if ($relateds = $this->getAmpSellerOrders($con)->toKeyValue('Id', 'Version')) {
            $version->setAmpSellerOrderIds(array_keys($relateds));
            $version->setAmpSellerOrderVersions(array_values($relateds));
        }
        $version->save($con);

        return $version;
    }

    /**
     * Sets the properties of the current object to the value they had at a specific version
     *
     * @param   integer $versionNumber The version number to read
     * @param   ConnectionInterface $con The connection to use
     *
     * @return  ChildAmpSeller The current object (for fluent API support)
     */
    public function toVersion($versionNumber, $con = null)
    {
        $version = $this->getOneVersion($versionNumber, $con);
        if (!$version) {
            throw new PropelException(sprintf('No ChildAmpSeller object found with version %d', $version));
        }
        $this->populateFromVersion($version, $con);

        return $this;
    }

    /**
     * Sets the properties of the current object to the value they had at a specific version
     *
     * @param ChildAmpSellerVersion $version The version object to use
     * @param ConnectionInterface   $con the connection to use
     * @param array                 $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects.
     *
     * @return ChildAmpSeller The current object (for fluent API support)
     */
    public function populateFromVersion($version, $con = null, &$loadedObjects = array())
    {
        $loadedObjects['ChildAmpSeller'][$version->getId()][$version->getVersion()] = $this;
        $this->setId($version->getId());
        $this->setRef($version->getRef());
        $this->setVisible($version->getVisible());
        $this->setAddress1($version->getAddress1());
        $this->setAddress2($version->getAddress2());
        $this->setAddress3($version->getAddress3());
        $this->setZipcode($version->getZipcode());
        $this->setCity($version->getCity());
        $this->setCountryId($version->getCountryId());
        $this->setEmail($version->getEmail());
        $this->setPhone($version->getPhone());
        $this->setFax($version->getFax());
        $this->setUrl($version->getUrl());
        $this->setFacebook($version->getFacebook());
        $this->setTwitter($version->getTwitter());
        $this->setPinterest($version->getPinterest());
        $this->setGoogle($version->getGoogle());
        $this->setYoutube($version->getYoutube());
        $this->setInstagram($version->getInstagram());
        $this->setLatitude($version->getLatitude());
        $this->setLongitude($version->getLongitude());
        $this->setCreatedAt($version->getCreatedAt());
        $this->setUpdatedAt($version->getUpdatedAt());
        $this->setVersion($version->getVersion());
        $this->setVersionCreatedAt($version->getVersionCreatedAt());
        $this->setVersionCreatedBy($version->getVersionCreatedBy());
        if ($fkValues = $version->getAmpSellerAdminIds()) {
            $this->clearAmpSellerAdmins();
            $fkVersions = $version->getAmpSellerAdminVersions();
            $query = ChildAmpSellerAdminVersionQuery::create();
            foreach ($fkValues as $key => $value) {
                $c1 = $query->getNewCriterion(AmpSellerAdminVersionTableMap::ID, $value);
                $c2 = $query->getNewCriterion(AmpSellerAdminVersionTableMap::VERSION, $fkVersions[$key]);
                $c1->addAnd($c2);
                $query->addOr($c1);
            }
            foreach ($query->find($con) as $relatedVersion) {
                if (isset($loadedObjects['ChildAmpSellerAdmin']) && isset($loadedObjects['ChildAmpSellerAdmin'][$relatedVersion->getId()]) && isset($loadedObjects['ChildAmpSellerAdmin'][$relatedVersion->getId()][$relatedVersion->getVersion()])) {
                    $related = $loadedObjects['ChildAmpSellerAdmin'][$relatedVersion->getId()][$relatedVersion->getVersion()];
                } else {
                    $related = new ChildAmpSellerAdmin();
                    $related->populateFromVersion($relatedVersion, $con, $loadedObjects);
                    $related->setNew(false);
                }
                $this->addAmpSellerAdmin($related);
                $this->collAmpSellerAdminsPartial = false;
            }
        }
        if ($fkValues = $version->getAmpSellerProductIds()) {
            $this->clearAmpSellerProduct();
            $fkVersions = $version->getAmpSellerProductVersions();
            $query = ChildAmpSellerProductVersionQuery::create();
            foreach ($fkValues as $key => $value) {
                $c1 = $query->getNewCriterion(AmpSellerProductVersionTableMap::ID, $value);
                $c2 = $query->getNewCriterion(AmpSellerProductVersionTableMap::VERSION, $fkVersions[$key]);
                $c1->addAnd($c2);
                $query->addOr($c1);
            }
            foreach ($query->find($con) as $relatedVersion) {
                if (isset($loadedObjects['ChildAmpSellerProduct']) && isset($loadedObjects['ChildAmpSellerProduct'][$relatedVersion->getId()]) && isset($loadedObjects['ChildAmpSellerProduct'][$relatedVersion->getId()][$relatedVersion->getVersion()])) {
                    $related = $loadedObjects['ChildAmpSellerProduct'][$relatedVersion->getId()][$relatedVersion->getVersion()];
                } else {
                    $related = new ChildAmpSellerProduct();
                    $related->populateFromVersion($relatedVersion, $con, $loadedObjects);
                    $related->setNew(false);
                }
                $this->addAmpSellerProduct($related);
                $this->collAmpSellerProductPartial = false;
            }
        }
        if ($fkValues = $version->getAmpSellerOrderIds()) {
            $this->clearAmpSellerOrder();
            $fkVersions = $version->getAmpSellerOrderVersions();
            $query = ChildAmpSellerOrderVersionQuery::create();
            foreach ($fkValues as $key => $value) {
                $c1 = $query->getNewCriterion(AmpSellerOrderVersionTableMap::ID, $value);
                $c2 = $query->getNewCriterion(AmpSellerOrderVersionTableMap::VERSION, $fkVersions[$key]);
                $c1->addAnd($c2);
                $query->addOr($c1);
            }
            foreach ($query->find($con) as $relatedVersion) {
                if (isset($loadedObjects['ChildAmpSellerOrder']) && isset($loadedObjects['ChildAmpSellerOrder'][$relatedVersion->getId()]) && isset($loadedObjects['ChildAmpSellerOrder'][$relatedVersion->getId()][$relatedVersion->getVersion()])) {
                    $related = $loadedObjects['ChildAmpSellerOrder'][$relatedVersion->getId()][$relatedVersion->getVersion()];
                } else {
                    $related = new ChildAmpSellerOrder();
                    $related->populateFromVersion($relatedVersion, $con, $loadedObjects);
                    $related->setNew(false);
                }
                $this->addAmpSellerOrder($related);
                $this->collAmpSellerOrderPartial = false;
            }
        }

        return $this;
    }

    /**
     * Gets the latest persisted version number for the current object
     *
     * @param   ConnectionInterface $con the connection to use
     *
     * @return  integer
     */
    public function getLastVersionNumber($con = null)
    {
        $v = ChildAmpSellerVersionQuery::create()
            ->filterByAmpSeller($this)
            ->orderByVersion('desc')
            ->findOne($con);
        if (!$v) {
            return 0;
        }

        return $v->getVersion();
    }

    /**
     * Checks whether the current object is the latest one
     *
     * @param   ConnectionInterface $con the connection to use
     *
     * @return  Boolean
     */
    public function isLastVersion($con = null)
    {
        return $this->getLastVersionNumber($con) == $this->getVersion();
    }

    /**
     * Retrieves a version object for this entity and a version number
     *
     * @param   integer $versionNumber The version number to read
     * @param   ConnectionInterface $con the connection to use
     *
     * @return  ChildAmpSellerVersion A version object
     */
    public function getOneVersion($versionNumber, $con = null)
    {
        return ChildAmpSellerVersionQuery::create()
            ->filterByAmpSeller($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }

    /**
     * Gets all the versions of this object, in incremental order
     *
     * @param   ConnectionInterface $con the connection to use
     *
     * @return  ObjectCollection A list of ChildAmpSellerVersion objects
     */
    public function getAllVersions($con = null)
    {
        $criteria = new Criteria();
        $criteria->addAscendingOrderByColumn(AmpSellerVersionTableMap::VERSION);

        return $this->getAmpSellerVersions($criteria, $con);
    }

    /**
     * Compares the current object with another of its version.
     * <code>
     * print_r($book->compareVersion(1));
     * => array(
     *   '1' => array('Title' => 'Book title at version 1'),
     *   '2' => array('Title' => 'Book title at version 2')
     * );
     * </code>
     *
     * @param   integer             $versionNumber
     * @param   string              $keys Main key used for the result diff (versions|columns)
     * @param   ConnectionInterface $con the connection to use
     * @param   array               $ignoredColumns  The columns to exclude from the diff.
     *
     * @return  array A list of differences
     */
    public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
    {
        $fromVersion = $this->toArray();
        $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();

        return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
    }

    /**
     * Compares two versions of the current object.
     * <code>
     * print_r($book->compareVersions(1, 2));
     * => array(
     *   '1' => array('Title' => 'Book title at version 1'),
     *   '2' => array('Title' => 'Book title at version 2')
     * );
     * </code>
     *
     * @param   integer             $fromVersionNumber
     * @param   integer             $toVersionNumber
     * @param   string              $keys Main key used for the result diff (versions|columns)
     * @param   ConnectionInterface $con the connection to use
     * @param   array               $ignoredColumns  The columns to exclude from the diff.
     *
     * @return  array A list of differences
     */
    public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
    {
        $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
        $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();

        return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
    }

    /**
     * Computes the diff between two versions.
     * <code>
     * print_r($book->computeDiff(1, 2));
     * => array(
     *   '1' => array('Title' => 'Book title at version 1'),
     *   '2' => array('Title' => 'Book title at version 2')
     * );
     * </code>
     *
     * @param   array     $fromVersion     An array representing the original version.
     * @param   array     $toVersion       An array representing the destination version.
     * @param   string    $keys            Main key used for the result diff (versions|columns).
     * @param   array     $ignoredColumns  The columns to exclude from the diff.
     *
     * @return  array A list of differences
     */
    protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
    {
        $fromVersionNumber = $fromVersion['Version'];
        $toVersionNumber = $toVersion['Version'];
        $ignoredColumns = array_merge(array(
            'Version',
            'VersionCreatedAt',
            'VersionCreatedBy',
        ), $ignoredColumns);
        $diff = array();
        foreach ($fromVersion as $key => $value) {
            if (in_array($key, $ignoredColumns)) {
                continue;
            }
            if ($toVersion[$key] != $value) {
                switch ($keys) {
                    case 'versions':
                        $diff[$fromVersionNumber][$key] = $value;
                        $diff[$toVersionNumber][$key] = $toVersion[$key];
                        break;
                    default:
                        $diff[$key] = array(
                            $fromVersionNumber => $value,
                            $toVersionNumber => $toVersion[$key],
                        );
                        break;
                }
            }
        }

        return $diff;
    }
    /**
     * retrieve the last $number versions.
     *
     * @param Integer $number the number of record to return.
     * @return PropelCollection|array \ArtabanMarketplace\Model\AmpSellerVersion[] List of \ArtabanMarketplace\Model\AmpSellerVersion objects
     */
    public function getLastVersions($number = 10, $criteria = null, $con = null)
    {
        $criteria = ChildAmpSellerVersionQuery::create(null, $criteria);
        $criteria->addDescendingOrderByColumn(AmpSellerVersionTableMap::VERSION);
        $criteria->limit($number);

        return $this->getAmpSellerVersions($criteria, $con);
    }
    /**
     * Code to be run before persisting the object
     * @param  ConnectionInterface $con
     * @return boolean
     */
    public function preSave(ConnectionInterface $con = null)
    {
        return true;
    }

    /**
     * Code to be run after persisting the object
     * @param ConnectionInterface $con
     */
    public function postSave(ConnectionInterface $con = null)
    {

    }

    /**
     * Code to be run before inserting to database
     * @param  ConnectionInterface $con
     * @return boolean
     */
    public function preInsert(ConnectionInterface $con = null)
    {
        return true;
    }

    /**
     * Code to be run after inserting to database
     * @param ConnectionInterface $con
     */
    public function postInsert(ConnectionInterface $con = null)
    {

    }

    /**
     * Code to be run before updating the object in database
     * @param  ConnectionInterface $con
     * @return boolean
     */
    public function preUpdate(ConnectionInterface $con = null)
    {
        return true;
    }

    /**
     * Code to be run after updating the object in database
     * @param ConnectionInterface $con
     */
    public function postUpdate(ConnectionInterface $con = null)
    {

    }

    /**
     * Code to be run before deleting the object in database
     * @param  ConnectionInterface $con
     * @return boolean
     */
    public function preDelete(ConnectionInterface $con = null)
    {
        return true;
    }

    /**
     * Code to be run after deleting the object in database
     * @param ConnectionInterface $con
     */
    public function postDelete(ConnectionInterface $con = null)
    {

    }


    /**
     * Derived method to catches calls to undefined methods.
     *
     * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
     * Allows to define default __call() behavior if you overwrite __call()
     *
     * @param string $name
     * @param mixed  $params
     *
     * @return array|string
     */
    public function __call($name, $params)
    {
        if (0 === strpos($name, 'get')) {
            $virtualColumn = substr($name, 3);
            if ($this->hasVirtualColumn($virtualColumn)) {
                return $this->getVirtualColumn($virtualColumn);
            }

            $virtualColumn = lcfirst($virtualColumn);
            if ($this->hasVirtualColumn($virtualColumn)) {
                return $this->getVirtualColumn($virtualColumn);
            }
        }

        if (0 === strpos($name, 'from')) {
            $format = substr($name, 4);

            return $this->importFrom($format, reset($params));
        }

        if (0 === strpos($name, 'to')) {
            $format = substr($name, 2);
            $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;

            return $this->exportTo($format, $includeLazyLoadColumns);
        }

        throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
    }

}
