Magento 2.3 – Multi store Product Name duplicates error

I have migrated Magento from 1.9.2.3 to 2.3.4, if i try to change the product details i am getting error like product name isn’t unique. I am using multi-Store so that the same product name available in all stores How to handle this issue? I can’t able to import the product images.

list manipulation – Deleting duplicates which are identified as equal up to rearrangement of sublists

I have a list of integer 2-tuples s = { {{3,4},{11,5}} , {{11,5},{3,4}}, {{5,5},{3,2}} } (in reality this set is much larger).

I am trying to delete duplicates from this list. Specifically, I want to treat lists within s which, up to a reordering, contain the same lists (2-tuples) as the same, and keep only one.

For instance, if s were my actual list, I would want to convert it into the following list: { {{3,4},{11,5}} , {{5,5},{3,2}} }.

I can’t figure out an efficient way of doing this; in reality, my list s is quite large, and its sublists also consist of many elements.

How to not allowe duplicates in asp.net entitiy framework

Hi i’m new to MVC and EF so this may be a really simple question but what is the best way to prevent the user from trying to enter duplicate records?

I have a table called Category with two colums Id and CategoryName (Id is PK and I set the Index value to unique one CategoryName). What I want to do is prevent the user from entering same categories. My CategoresController looks like :

   using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Library;

namespace Library.Controllers
{
    public class CategoriesController : Controller
    {
        private LibraryDbEntities1 db = new LibraryDbEntities1();

        // GET: Categories
        public ActionResult Index()
        {
            return View(db.Category.ToList());
        }

        // GET: Categories/Details/5
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Category category = db.Category.Find(id);
            if (category == null)
            {
                return HttpNotFound();
            }
            return View(category);
        }

        // GET: Categories/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: Categories/Create
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        (HttpPost)
        (ValidateAntiForgeryToken)
        public ActionResult Create((Bind(Include = "Id,CategoryName")) Category category)
        {
            if (ModelState.IsValid)
            {
                db.Category.Add(category);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            int temp = Convert.ToInt32(cmd.ExcecuteScalar().To)

            return View(category);

            
        }

        // GET: Categories/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Category category = db.Category.Find(id);
            if (category == null)
            {
                return HttpNotFound();
            }
            return View(category);
        }

        // POST: Categories/Edit/5
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        (HttpPost)
        (ValidateAntiForgeryToken)
        public ActionResult Edit((Bind(Include = "Id,CategoryName")) Category category)
        {
            if (ModelState.IsValid)
            {
                db.Entry(category).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(category);
        }

        // GET: Categories/Delete/5
        public ActionResult Delete(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Category category = db.Category.Find(id);
            if (category == null)
            {
                return HttpNotFound();
            }
            return View(category);
        }

        // POST: Categories/Delete/5
        (HttpPost, ActionName("Delete"))
        (ValidateAntiForgeryToken)
        public ActionResult DeleteConfirmed(int id)
        {
            Category category = db.Category.Find(id);
            db.Category.Remove(category);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}

The index view looks like this:

  @model Library.Category

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>


@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>Category</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Id, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.CategoryName, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.CategoryName, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.CategoryName, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

MY question is: how can I prevent the user from entering the same category two times? For example I create a category named "Action", I dont want any other user to be able to create the same Category.

Thanks a lot!

java – Remove Duplicates from the ArrayList

I know that this challenge can be solved using HashSets, but what is the disadvantage of this way except the time complexity.

    public ArrayList<String>removeDuplicates(ArrayList<String>emails){
    String m="";
    for(int i=0; i<emails.size(); i++){
        if(m.contains(emails.get(i))){
            System.out.println(emails.get(i)+" is duplicated");
            emails.remove(emails.get(i));
        }
        else{
            m+=emails.get(i);
            m+='|';
        }
    }
    return emails;
}

dnd 5e – Can I “High Five” my duplicates from the Mirror Image spell?

The text for Mirror Image says:

the duplicates move with you and mimic your actions […] If an attack hits a duplicate, the duplicate is destroyed.

Does this mean that my warlock can cast Mirror Image, slay an opponent in the first two rounds, then spend the remaining eight rounds giving himself one high five after another? Then wave goodbye to the three images when the spell duration expires normally?

Or does one high five from the caster destroy his own duplicate? One destroyed image with each flat palm slap?

Assume that at the end of round two, no opponent has hit a duplicate, and the three original duplicates are still present when celebratory hand gestures commence.

python – Minimum number of swaps to sort an array that has duplicates and 3 distinct numbers with N numbers

I’m not sure how to find the minimum amount of swaps to sort an array that has duplicates with N total numbers. The array is made up of 3 distinct numbers, 1, 2 and 3.

So for example, the minimum amount of swaps to sort the array (2, 2, 1, 3, 3, 3, 2, 3, 1) would be 4. You could sort this array in 4 swaps by doing swap((3), (8)), swap((4), (6)), swap((0), (3)), swap((1), (2))

The array itself would change as so.

2 2 1 3 3 3 2 3 1, swap((3), (8))

2 2 1 1 3 3 2 3 3, swap((4), (6))

2 2 1 1 2 3 3 3 3, swap((0), (3))

1 2 1 2 2 3 3 3 3, swap((1), (2))

1 1 2 2 2 3 3 3 3

This is my first time writing a question, so I apologize in advance for any mistakes or information I didn’t include.

oracle – Why is my view selecting hundreds of duplicates?

This view selects 696 entries. The CSV file has 48 entries.

CREATE OR REPLACE VIEW insert_3_char_abts AS SELECT
    ext.construct_id,
    n_term,
    enz_name,
    c_term,
    cpp,
    mutations,
    ext.g_batch,
    ext.p_batch,
    emptycol,
    
    c_batch,
    abts5_mean,
    abts5_SD,
    abts5_n,
    abts5_method,
    abts5_study_id,
    abts7_mean,
    abts7_SD,
    abts7_n,
    abts7_method,
    abts7_study_id,
    pur.pk_purified_enz_id
FROM EXTERNAL (( 
      construct_id NUMBER(10),
      n_term VARCHAR2 (50),
      enz_name VARCHAR2 (50),
      c_term VARCHAR2 (50),
      cpp VARCHAR2 (50),
      mutations VARCHAR2 (50),
      g_batch VARCHAR2 (50),
      p_batch VARCHAR2 (50),
      emptycol VARCHAR2(50),

      c_batch VARCHAR2 (50),
      abts5_mean NUMBER (5, 2),
      abts5_SD NUMBER (5, 2),
      abts5_n NUMBER (3),
      abts5_method VARCHAR2 (50),
      abts5_study_id VARCHAR2 (8),
      abts7_mean NUMBER (5, 2),
      abts7_SD NUMBER (5, 2),
      abts7_n NUMBER (3),
      abts7_method VARCHAR2 (50),
      abts7_study_id VARCHAR2 (8))
      
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY data_to_input
    ACCESS PARAMETERS (
        RECORDS DELIMITED BY NEWLINE 
        SKIP 1
        BADFILE bad_files:'badflie_view_before_insert_char_abts.bad'
        FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
        MISSING FIELD VALUES ARE NULL 
        ) 
    LOCATION ('CHAR_ABTS.CSV')
    REJECT LIMIT UNLIMITED) ext 
INNER JOIN purified_enz pur
ON ext.p_batch = pur.p_batch
INNER JOIN produced pr 
ON pr.pk_produced_id = pur.fk_produced_id;
;

If I finish this statement with

AND pr.fk_construct_id = ext.construct_id;

It selects 46 out of 48 records, which is better, but not great.

list manipulation – Deleting duplicates after n-occurrences

As a generalization of DeleteDuplicates, I want to delete duplicates from a list, but only after n number of duplicates.

Say, n = 3 means that three duplicates are allowed.

I made my own function:

DeleteDuplicatesN(x_, n_) := 
  x((
    Sort(
      Flatten(((1 ;; Min(Length(#), n)))& /@ 
       (Flatten(Position(x, #))& /@ DeleteDuplicates(x))))))

DeleteDuplicatesN({1, 2, 3, 2, 1, 1, 1, 2, 3, 5, 5, 5, 5, 1, 7, 4, 7, 1}, 3)
{1, 2, 3, 2, 1, 1, 2, 3, 5, 5, 5, 7, 4, 7}

Is there a better method — faster or more elegant?

For example, using only DeleteDuplicates or DeleteDuplicatesBy?

sql server – SUM and JOIN 2 columns with different tables but it duplicates results

SELECT DISTINCT
(Transfer Shipment Line).(Transfer-to Code) AS (Loc Code)
,(Transfer Shipment Line).(Item No_)
,(Transfer Shipment Line).(Description)
,(Transfer Shipment Line).(Description 2)
,(Transfer Shipment Line).(Variant Code)
,(Transfer Shipment Line).(Quantity) AS (QTY)
FROM (Transfer Shipment Line)
LEFT JOIN (Trans_ Sales Entry)
ON (Transfer Shipment Line).(Transfer-to Code)=(Trans_ Sales Entry).(Store No_) AND
(Transfer Shipment Line).(Item No_)=(Trans_ Sales Entry).(Item No_) AND
(Transfer Shipment Line).(Variant Code)=(Trans_ Sales Entry).(Variant Code)
WHERE
(Transfer Shipment Line).(Transfer-to Code)='LOCATION1' AND
(Transfer Shipment Line).(Item No_)='ITEM01' AND
(Transfer Shipment Line).(Variant Code)='VARIANT01'

Query result (correct quantity)

Loc Code   -   Item No_   -   Description   -   Description2   -   Variant Code   -   QTY
LOCATION1   ITEM01         ACTIVE            BLACK                VARIANT01          1
LOCATION1   ITEM01         ACTIVE            BLACK                 VARIANT01         2

SUM QUERY

SELECT DISTINCT
MAX((Transfer Shipment Line).(Transfer-to Code)) AS (Loc Code)
,MAX((Transfer Shipment Line).(Item No_))
,MAX((Transfer Shipment Line).(Description))
,MAX((Transfer Shipment Line).(Description 2))
,MAX((Transfer Shipment Line).(Variant Code))
,SUM((Transfer Shipment Line).(Quantity)) AS (QTY)
FROM (Transfer Shipment Line)
LEFT JOIN (Trans_ Sales Entry)
ON (Transfer Shipment Line).(Transfer-to Code)=(Trans_ Sales Entry).(Store No_) AND
(Transfer Shipment Line).(Item No_)=(Trans_ Sales Entry).(Item No_) AND
(Transfer Shipment Line).(Variant Code)=(Trans_ Sales Entry).(Variant Code)
WHERE
(Transfer Shipment Line).(Transfer-to Code)='LOCATION1' AND
(Transfer Shipment Line).(Item No_)='ITEM01' AND
(Transfer Shipment Line).(Variant Code)='VARIANT01'
GROUP BY
(Transfer Shipment Line).(Transfer-to Code)
,(Transfer Shipment Line).(Item No_)
,(Transfer Shipment Line).(Variant Code)

Query result (with SUM)

Loc Code   -   Item No_   -   Description   -   Description2   -   Variant Code   -   QTY
LOCATION1   ITEM01         ACTIVE            BLACK                VARIANT01          9

 if i remove the DISTINCT from 1st query, it duplicates the result also

Loc Code   –   Item No_   –   Description   –   Description2   –   Variant   –   QTY

LOCATION1   ITEM01         ACTIVE            BLACK                VARIANT01          2

LOCATION1   ITEM01         ACTIVE            BLACK                VARIANT01          2

LOCATION1   ITEM01         ACTIVE            BLACK                VARIANT01          2

LOCATION1   ITEM01         ACTIVE            BLACK                VARIANT01          1

LOCATION1   ITEM01         ACTIVE            BLACK                VARIANT01          1

LOCATION1   ITEM01         ACTIVE            BLACK                VARIANT01          1

google sheets – highlight if value is duplicate and corresponding cell of all other duplicates is blank

(Please adjust columns and row numbers accordingly)

The formula you need for column L (or even better columns L to M) is:

=and(COUNTIFS($L$11:$L11, $L11)>1, not($M11=""))

Conditional formatting duplicates except first when next column not empty

Please note that the way the formula is structured, will NOT highlight the first instance.

If you want the first instance/occurance to be highlighted as well, the formula would be:

=and(COUNTIFS($L$11:$L, $L11)>1, not($M11=""))