Useful scripts to import/export/assign things in Magento
I've used and tested this in Magento 1.9. Take care.
I've not created all of this just by myself. These scripts were created based on old scripts provided by rafaldimas and questions, like following:
- Put your order ids in the respective array:
$ordersIds = array(
'1',
'2',
);- Then, add the status slug and comment:
$order->addStatusToHistory('complete_shipped', 'Status comment');- Access YOUR_SITE.XYZ/alter-status-add-comment.php
- Use the
sku2sku.csvmodel.
- First column for your old SKUs
- Second column for your new SKUs
-
Upload the .csv file to
/var/exportdirectory -
Upload the script file
updateskus.phpto your root directory -
Access YOUR_SITE.XYZ/updateskus.php
- Use the
category_assign.csvmodel.
- First column for your SKUs
-
Upload the .csv file to
/var/exportdirectory -
Upload the script file
category_assign.phpto your root directory -
Put the category ids in the respective array in
category_assign.php:
$categories = array(2, 136, 470);- Access YOUR_SITE.XYZ/category_assign.php
- Use the
website_assign.csvmodel.
- First column for your SKUs
-
Upload the .csv file to
/var/exportdirectory -
Upload the script file
website_assign.phpto your root directory -
Put the website ids in the respective array in
website_assign.php:
$websites = array(1, 2);- Access YOUR_SITE.XYZ/website_assign.php
- Change the $storeId in
get_payment_methods_codes.phptou YOUR store id:
$storeId = 1;-
Upload the script file
get_payment_methods_codes.phpto your root directory -
Access YOUR_SITE.XYZ/get_payment_methods_codes.php
- Use the
disable_products_by_sku.csvmodel.
- First column for your SKUs
-
Upload the .csv file to
/var/exportdirectory -
Upload the script file
disable_products_by_sku.phpto your root directory -
Access YOUR_SITE.XYZ/disable_products_by_sku.php
- Use the
set_attributes.csvmodel.
- First column for your attribute names
- Second column form their values
-
Upload the .csv file to
/var/exportdirectory -
Upload the script file
set_attributes.phpto your root directory -
Access YOUR_SITE.XYZ/set_attributes.php
-
Upload the script file
update_orders_status.phpto your root directory -
Set your date interval:
$from = new DateTime('2020-01-01 00:00:00');
$from = $from->format('Y-m-d H:i:s');
$to = new DateTime('2020-12-22 23:59:9');
$to = $to->format('Y-m-d H:i:s');- Define your current order status for search:
->addFieldToFilter('status', 'complete_shipped')- Define the final status:
$order->addStatusToHistory('complete', 'Status manually updated on ' . date("d - m - Y") . '.');- Access YOUR_SITE.XYZ/update_orders_status.php