Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    help question How do we copy product attributes to multiple product IDs using MYSQL script?

    Hello,

    One of our girls has been listing new products to our website but she has forgotten to include an attribute drop down menu for tartan choice selection. The listings should look like this one::

    https://www.silkblooms.co.uk/Gorgeou...ttonhole-12268 (you see the tartan selection drop menu).

    There are several hundred products on the site, like this::

    https://www.silkblooms.co.uk/Scottis...-Heather-15409 (missing the drop menu).

    I know you can copy attributes from product to another using the admin feature under attributes controller. However, we need an SQP script that will copy the tartn drop down attributes from one product to a list of product ID's, seperated by commas.

    Can anyone help with such a script?

  2. #2
    Join Date
    Feb 2009
    Location
    UK
    Posts
    478
    Plugin Contributions
    0

    Default Re: How do we copy product attributes to multiple product IDs using MYSQL script?

    Not sure if this is any help but, I regularly add attributes to multiple products in phpmyadmin. Perhaps you could insert new attributes rather than copy existing.

    I use:

    Code:
    INSERT INTO `products_attributes`(`products_id`, `options_id`, `options_values_id`, `options_values_price`,`products_options_sort_order`, `product_attribute_is_free`,`attributes_discounted`) SELECT products_id,'32','162','8.49','4000','0','0' FROM `products`
    WHERE `products_model` LIKE '123456'
    AND `master_categories_id`
    IN (
    1462,1465,1414,1470,1473,1468,1464,1463,1469,1466,1387,1386,1370,1389,1373,1396,1392,1391,1376,1393,1377,1398,1385,1374,1371,1390,1375,1372,1320,1384,1395,1394,1397,1361,1416,1378,1421,1354,1380,1457,1400,1417,1422,1379,1418,1363,1792,1381,1399,1419,1312,1420,1423,1424,1427,1426,1428,1415,1401,1403,1450,1333,1405,1402,1407,1410,1412,1409,1408,1413,1325,1538,1458,1429,1330,1309,1425,1327,1328,1334,1329,1369,1332,1337,1336,1326,1331,1324,1323,1313,1311,1310,1314,1338,1319,1315,1322,1321,1316,1318,1317,1339,1356,1358,1355,1357,1353,1359,1362,1365,1366,1367,1360,1340,1349,1341,1346,1345,1350,1343,1347,1348,1511,1507,1505,1503,1491,1504,1508,1516,1506,1513,1514,1517,1485,1490,1411,1368,1352,1510,1489,1515,1351,1492,1509,1493,1502,1501,1499,1467,1494,1519,1498,1495,1497,1518,1496,1512,1500,1520,1541,1548,1546,1536,1539,1534,1537,1540,1544,1542,1547,1545,1521,1522,1523,1525,1526,1364,1342,1476,1483,1448,1453,1527,1449,1524,1530,1447,1532,1446,1535,1528,1451,1486,1335,1406,1344,1533,1543,1529,1452,1488,1455,1531,1382,1454,1439,1444,1440,1430,1432,1445,1431,1435,1437,1434,1436,1433,1456,1438,1442,1441,1461,1471,1472,1443,1459,1460,1481,1475,1477,1480,1478,1479,1482,1404,1484,1487,1474);
    this adds attributes to multiple products with the same model number in a number of categories, but I wonder if omitting the model number and substituting master_categories_id for products_id would work, like:

    Code:
    INSERT INTO `products_attributes`(`products_id`, `options_id`, `options_values_id`, `options_values_price`,`products_options_sort_order`, `product_attribute_is_free`,`attributes_discounted`) SELECT products_id,'32','162','8.49','4000','0','0' FROM `products`
    WHERE `products_id'
    IN (
    1462,1465,1414,1470,1473,1468,1464,1463,1469,1466,1387,1386,1370,1389,1373,1396,1392,1391,1376,1393,1377,1398,1385,1374,1371,1390,1375,1372,1320,1384,1395,1394,1397,1361,1416,1378,1421,1354,1380,1457,1400,1417,1422,1379,1418,1363,1792,1381,1399,1419,1312,1420,1423,1424,1427,1426,1428,1415,1401,1403,1450,1333,1405,1402,1407,1410,1412,1409,1408,1413,1325,1538,1458,1429,1330,1309,1425,1327,1328,1334,1329,1369,1332,1337,1336,1326,1331,1324,1323,1313,1311,1310,1314,1338,1319,1315,1322,1321,1316,1318,1317,1339,1356,1358,1355,1357,1353,1359,1362,1365,1366,1367,1360,1340,1349,1341,1346,1345,1350,1343,1347,1348,1511,1507,1505,1503,1491,1504,1508,1516,1506,1513,1514,1517,1485,1490,1411,1368,1352,1510,1489,1515,1351,1492,1509,1493,1502,1501,1499,1467,1494,1519,1498,1495,1497,1518,1496,1512,1500,1520,1541,1548,1546,1536,1539,1534,1537,1540,1544,1542,1547,1545,1521,1522,1523,1525,1526,1364,1342,1476,1483,1448,1453,1527,1449,1524,1530,1447,1532,1446,1535,1528,1451,1486,1335,1406,1344,1533,1543,1529,1452,1488,1455,1531,1382,1454,1439,1444,1440,1430,1432,1445,1431,1435,1437,1434,1436,1433,1456,1438,1442,1441,1461,1471,1472,1443,1459,1460,1481,1475,1477,1480,1478,1479,1482,1404,1484,1487,1474);
    the comma separated values in the latter would obviously be product ids and you wouldn't need to add all the attributes I did.

    (some of the apostrophe's may have got corrupted in my copy and pasting)
    Last edited by simon1066; 27 Nov 2017 at 03:27 PM.

 

 

Similar Threads

  1. Updating product price by MySQL gives copy of product
    By veryveryinteresting in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 27 Apr 2013, 04:53 PM
  2. Newbie: How do I copy Attributes and assign them to multiple product?
    By hugozc in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 2 May 2009, 01:44 PM
  3. how to copy attributes from one product to another?
    By gsdcypher in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 21 Jun 2007, 06:15 PM
  4. 1 product, 1 set of attributes, many product ids
    By freef4ll in forum Setting Up Categories, Products, Attributes
    Replies: 6
    Last Post: 4 Jan 2007, 09:52 PM
  5. Multiple attributes using same options on one product
    By jbhansen in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 23 Dec 2006, 06:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR