magento2 – Importing existing products: Integrity constraint violation: 1062 Duplicate Entry

I have been importing existing products to a local environment through the admin dashboard. I realized that many of the products I imported didn’t include their attributes, so I went back to make sure they were included by changing the ‘Multiple value separator’ to a pipe. Now though, when I import I get the following error:

General system exception happened
Additional data:
SQLSTATE(23000): Integrity constraint violation: 1062 Duplicate entry 'sauces-rubs/healthy-choices/gluten-free-default-category/healthy' for key 'url_rewrite.URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`store_id`,`entity_type`,`entity_id`,`request_path`,`target_path`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)

I have deleted all products and categories, I have wiped the url_rewrites table clean, and I have attempted to regenerate them using this module. What am I missing? I am new to Magento, so please let me know if I need to include more information, but this is all that I am aware of at the moment.

php – Laravel 8: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

I want to apply OneToMany Relationship between users and roles table and I have already some data in these two tables.

So in order to make this relationship, I made this Migration for adding role_id to users table:

public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->unsignedBigInteger('role_id')->nullable()->unsigned();
            $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
        });
    }

But when I want to run this Migration, I get this error:

SQLSTATE(42S21): Column already exists: 1060 Duplicate column name
‘role_id’ (SQL: alter table users add role_id bigint unsigned
null)

So what is going wrong here ? How can I fix this issue ?

Here is also the Migration of roles table:

public function up()
    {
        Schema::create('roles', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('slug');
            $table->timestamps();
        });
    }

magento2.3 – Magento 2 Data Migration “Integrity constraint violation: 1062 Duplicate entry ### for key ‘SALES_CREDITMEMO_INCREMENT_ID_STORE_ID

I’ve been having issues while using the data migration tool to migrate data from Magento 1.9.3 to Magento 2.3:

I already setup the config.xml to migrate only Customers and Sales. I then run the following commands:

php bin/magento migrate:settings –reset vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.8/config.xml

php bin/magento migrate:data –auto vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.8/config.xml

and then get the following error:

In Mysql.php line 182:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘100000003-1’ for key ‘SALES_CREDITMEMO_INCREMENT_ID_STORE_ID’

The Magento 2 database sales_creditmemo_* tables are all empty, so I’m clueless.
Any help is greatly appreciated.

mysql – SQLSTATE[42000]: Syntax error or access violation: 1055

Buenas tardes a todos,

La cosa es la siguiente, necesito hacer un join donde interacturan 3 tablas:

  1. Pedidos / Información de un inmueble , hay una foreign key que sirve para referenciar el cliente de contacto, que estan guardados en una tabla a parte (FK: cliente_id (clientes.id))
  2. Clientes / Donde se guarda la informacion del cliente ( No hay ninguna FK aqui, para tener referencia del pedido con el cliente lo enlazo desde pedidos a clientes con la fk “cliente_id”
  3. Pedido_zonas_interes / En los pedidos, hay un multi-select que permite elegir varias zonas de interes para la busqueda, así que tengo una tabla dónde guardo los diferentes sitios y los vinculo al pedido mediante una (FK: pedido_id (pedidos.id))

La cosa es que estoy intentado hacer un join para unir toda esta información y mostrarla en pantalla con Laravel, pero no lo consigo….

Con esta consulta Mysql consigo los resultados, sin duplicarlos! Me refiero que los agrupo por la id del pedido, y asi veo todos los pedidos ( que es lo que me interesa)

SELECT pe.*, cl.*, pe_zo.* from pedidos pe 
inner join clientes cl ON cl.id = pe.cliente_id 
inner join pedidos_zonas_interes pe_zo ON pe_zo.pedido_id = pe.id 
GROUP by pe.id

El problema es que no consigo replicar esta consulta usando DB::table ni Pedido::Join….

-He intentado mediante Eloquent:

$pedidos = Pedido::join('clientes', 'clientes.id', '=', 'pedidos.cliente_id')
 ->join('pedidos_zonas_interes', 'pedidos_zonas_interes.pedido_id', '=', 'pedidos.id')
 ->groupBy('pedidos.id')->get();

Pero me da error…..

SQLSTATE(42000): Syntax error or access violation: 1055 'pjcominm_laravel_crm_dev.pedidos.cliente_id' isn't in GROUP BY (SQL: select * from `pedidos` inner join `clientes` on `clientes`.`id` = `pedidos`.`cliente_id` inner join `pedidos_zonas_interes` on `pedidos_zonas_interes`.`pedido_id` = `pedidos`.`id` group by `pedidos`.`id`)

-También lo he intentado con El constructor de consultas de Laravel

$data = DB::table('clientes')
      ->join('pedidos', 'pedidos.cliente_id', '=', 'clientes.id')
      ->join('pedidos_zonas_interes', 'pedidos_zonas_interes.pedido_id', '=', 'pedidos.id')
      ->select('pedidos.*', 'clientes.*','pedidos_zonas_interes.*')
      ->groupBy('pedidos.id')
      ->get();

Pero me da el mismo error..

SQLSTATE(42000): Syntax error or access violation: 1055 'pjcominm_laravel_crm_dev.pedidos.cliente_id' isn't in GROUP BY (SQL: select `pedidos`.*, `clientes`.*, `pedidos_zonas_interes`.* from `clientes` inner join `pedidos` on `pedidos`.`cliente_id` = `clientes`.`id` inner join `pedidos_zonas_interes` on `pedidos_zonas_interes`.`pedido_id` = `pedidos`.`id` group by `pedidos`.`id`)

Algo me esta fallando, por que en mi SQL saco 2 resultados , cambiando un poco las sentencias en los query builder, sin filtrarlo por “groupBy” he conseguido sacar los resultados, pero 8 resultados.. cuando solo hay 2 pedidos

Python ctypes access violation due to invalid pointer

I have a dll and its header file that define quite a number of functions to access data in a special format. Following other solutions, I am able to get a basic start with ctypes that seems to work but as soon as I attempt to use a returned file pointer I receive the access violation so I suspect I am using the pointers incorrectly.

I’m following example code in C which lays out creating a new context, then opening the file, so I believe that part is ok. I just can’t seem to do anything with the returned file reference. I do get file returned as an int after calling sie_file_open whereas the documentation says that the errors from the library return null. I’ve got a bunch of different functions to use with the file pointer, but even the most basic sie_release fails.

Taking the advice from here to use classes to manage the pointers (there will be many more needed to access the data later), I have:

from ctypes import *

libsie = cdll.LoadLibrary('libsie.dll')

#Set the SIE context
class pt_sie_context(c_void_p):
    pass

libsie.sie_context_new.argtypes = None
libsie.sie_context_new.restype = pt_sie_context

context = libsie.sie_context_new()

#Open the SIE file
class pt_sie_file(c_void_p):
    pass

libsie.sie_file_open.argtypes = (pt_sie_context,c_char_p)
libsie.sie_file_open.restypes = pt_sie_file

fpath = 'H2.sie'
file = libsie.sie_file_open(context,fpath.encode('utf-8'))

libsie.sie_release.argtypes = (pt_sie_file)
libsie.sie_release.restypes = None

libsie.sie_release(file) #access violation here

And from the header file:

typedef void sie_Context;
typedef void sie_File;

SIE_DECLARE(sie_Context *) sie_context_new(void);
SIE_DECLARE(sie_File *) sie_file_open(void *context_object, const char *name);
SIE_DECLARE(void) sie_release(void *object);

I’m relatively new to this whole process as well as C in general so any thoughts would be much appreciated.

M1 to M2 migration – SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

I am in the process of migrating a site from M1 to M2

I have run the following command successfully a few times:

bin/magento migrate:delta --auto /app/code/Vendor/Migration/etc/opensource-to-opensource/1.9.4.5/config.xml

The last time I ran it the following error was displayed:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1617
  3-1' for key 'CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID'

Any ideas?

c++ – Access violation when trying to add an element in a DynamicArray

I can’t figure out why i get this error. (My guess would be that perhaps i have to add something to Movie class so that i can use the “=” sign for allocating it, but i don’t know how)

Well, i have a DynamicVector class which contains elements of type “Movie”

template <class T> class DynamicVector
{
    private:
        // arr is the integer pointer
        // which stores the address of our vector
        T* vector;

        // capacity is the total storage
        // capacity of the vector
        int capacity;

        // current is the number of elements
        // currently present in the vector
        int nr_elements;

    public:
        // Default constructor to initialise
        // an initial capacity of 1 element and
        // allocating storage using dynamic allocation
        DynamicVector(){

            vector = new T(2);
            capacity = 2;
            nr_elements = 0;
        }

        // destructor
        ~DynamicVector(){
            delete() vector;
        }

        // increases the capacity of the vector if needed
        void match_capacity(){
            if (nr_elements == capacity) {
                T* temporary_vector = new T(2 * capacity);

                // copying old vector elements to the new one
                for (int i = 0; i < capacity; i++)
                    temporary_vector(i) = vector(i);

                // deleting previous vector
                delete() vector;
                capacity *= 2;
                vector = temporary_vector;
            }
        }

        // Function to add an element at the last
        void add(T new_element){

            // If the current vector is full, we make it bigger
            match_capacity();

            // Inserting data
            vector(nr_elements) = new_element;
            nr_elements++;
        }

The Movie class looks like this:

//Movie.h
class Movie {

    private:
        string title;
        string genre;
        int year;
        int likes;
        string trailer;

    public:
    Movie(string title="", string genre="", int year=0, int likes=0, string trailer="");
    ~Movie();
    string get_title() const;
    string get_genre() const;
    int get_year() const;
    int get_likes() const;
    string get_trailer() const;
    void set_title(string new_title);
    void set_genre(string new_genre);
    void set_year(int new_year);
    void set_likes(int new_likes);
    void set_trailer(string new_trailer);
    string to_string() const;
};
Movie::Movie(string title, string genre, int year, int likes, string trailer){
    this->title = title;
    this->genre = genre;
    this->year = year;
    this->likes = likes;
    this->trailer = trailer;
}

Movie::~Movie() = default;

std::string Movie::get_title() const {
    return this->title;
}

std::string Movie::get_genre() const {
    return this->genre;
}

int Movie::get_year() const {
    return this->year;
}

int Movie::get_likes() const {
    return this->likes;
}

std::string Movie::get_trailer() const {
    return this->trailer;
}

void Movie::set_title(string new_title){
    this->title = new_title;
}

void Movie::set_genre(string new_genre){
    this->genre = new_genre;
}

void Movie::set_year(int new_year){
    this->year = new_year;
}

void Movie::set_likes(int new_likes){
    this->likes = new_likes;
}

void Movie::set_trailer(string new_trailer){
    this->trailer = new_trailer;
}

string Movie::to_string() const{
    string s;
    s += "Movie with title: " + this->title;
    s += "ntgenre: " + this->genre;
    s += "ntyear: " + std::to_string(this->year);
    s += "ntlikes: " + std::to_string(this->likes);
    s += "nttrailer: " + this->trailer;
    return s;
}

I have used the class DynamicVector in a movie database class, and when i try to add a new movie to it using the function below, the code exits with: “Exception 0xc0000005 encountered at address 0x70ff411f: Access violation writing location 0x00200020”

this->movies.add(m);
//this->movies is an instance of type DynamicVector
        void add(T new_element){

            // If the current vector is full, we make it bigger
            match_capacity();

            // Inserting data
            // -----------LINE BELOW CRASHES---------------
            vector(nr_elements) = new_element;
            nr_elements++;

        }

database – Integrity constraint violation 1062 ALTER TABLE on setup:upgrade

Magento ver. 2.3.5
mariadb 10.2
PHP 7.2

We are hitting the constraint violation error below when running: php bin/magento setup:upgrade
catalog_product_entity_varchar ran out of space at 2147483647 so we increased the value_id int to Bigint.
We are able to edit and add products again. But now have the constraint error coming up when it reaches schema / update.
What is the best way to correct this, can we change the constraint rule?

SQLSTATE(23000): Integrity constraint violation:
1062 ALTER TABLE causes auto_increment resequencing,
resulting in duplicate entry ‘2147483647’ for key ‘PRIMARY’,
query was: ALTER TABLE catalog_product_entity_varchar MODIFY COLUMN
value_id int(11) NOT NULL AUTO_INCREMENT COMMENT “Value ID”

Thanks so much.
Tony

accessibility – Is specifying link colours a violation against WCAG’s Success Criterion 1.4.8?

The text of the WCAG’s Success Criterion 1.4.8 page says:

Success Criterion 1.4.8 Visual Presentation (Level AAA): For the visual presentation of blocks of text, a mechanism is available to achieve the following:

Foreground and background colors can be selected by the user.

One may choose from five different given techniques to satisfy this part of the criterion: C23, C25, G156, G148, or G175. The latter, G175, states that a colour-picking tool must be provided.

All the others techniques except for G156, however, explicitly mention that no background and no foreground colour must be specified for the texts, at least not for the main content’s texts.

However, is specifying colours for the links in those texts (supposing no colour-picking tool is provided on the page) a violation against Success Criterion 1.4.8, or is it satisfactory due to the fact most modern browsers are compatible with the demands of the technique G156, since they let the users change the page’s colours?

If so, then is it acceptable to specify background and foreground colours also for the main content’s text, given browsers let the users change these specifications?