magento
Magento2 Create Simple Product via Rest in PHP
In this wiki we will see how can we create new simple product using rest in magento2.
- First let us write the configurations (URL's,username,password)
// configuration Data $url="http://www.example.com/index.php/"; $token_url=$url."rest/V1/integration/admin/token"; $product_url=$url. "rest/V1/products"; $username="your admin username"; $password="your admin password";
- Then let us get access token
Magento2 Create Invoice for Order Direclty By PHP code
Kindly i am share with you the code of how to make partial Invoice for existing Order in Magento2
I will write the code that can be executed external of magento files
First Create new file and name it as you want , For me i named it (create-invoice-magento2.php)
add this code to the file
Magento2 Upgrade current installation using command line
Hello In this wiki i will show you how to upgrade magento to (CC 2.3.6) version by Command line
Please follow these steps
direct use of composer.phar
To see the full list of available 2.3 versions:
composer show magento/product-community-edition 2.3.* --available | grep -m 1 versions
To see the full list of available 2.4 versions:
composer show magento/product-community-edition 2.4.* --available | grep -m 1 versions
Create category in magento2 programmatically
In this we are going to see how we can create category in Magento2 programmatically,
First we need to have the ObjectManager by this code
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
Then let us have array with some Categories names
$cats = [ "cat1","cat2" ];
Let us setup the Parent Id of the categories
$parent_id = 322;
After that we will going throw the arrays items to create those categories
Magento2 Module Creator Script
In this wiki , I will explain how can we use the class that we create to build Magento module
The Script will provide
Magento2 Create Bundle Product via Rest in PHP
Product bundles are several individual goods or services that are sold to consumers as one combined package. Sometimes called "package deals," product bundles are generally made up of complementary items or, less frequently, similar items. When retailers offer multiples of the exact same item, this is generally referred to as a "multipack," not a product bundle (1). Examples of product bundles would be a fixed-price meal at a restaurant or a beach kit that includes sunscreen, sand toys, flip flops and towels as one saleable item.
Generate data for performance testing
To Generate data for performance testing, you can use those four profiles,
1- Small profile (small.xml)
2- Medium profile (medium.xml)
3- Large profile (large.xml)
4- Extra large profile (extra_large.xml)
and you can install the profile using SSH commadn
1- first go to the magento root folder.
2- type this comand
php bin/magento setup:perf:generate-fixtures {path to profile path}
The files are exist in this path
{magento root} /setup/performance-toolkit/profiles/ce
Magento2 Deploy specific theme with specific locale language
In this wiki, i will show you how to deploy the static content for specific theme and the locale languages
First of all, we know that the Deploy command is
php bin/magento setup:static-content:deploy
Now , if you need to deploy a theme we need to use this command
theme name : {vendor}/{them name}
Command: php bin/magento setup:static-content:deploy --theme {vendor}/{them name}
if you want to deploy many locale you can use this command
locales are : en_US, fr_FR
Log In By Customer ID
Magento1
// for security we should add custom IP $IP = "192.168.0.1"; $customer_id = 1; if($_SERVER['REMOTE_ADDR']==$IP){ Mage::getSingleton ( 'customer/session' )->loginById ( $customer_id ); }
Magento2
Display PHTML file or Static Block in CMS page Magento2
Yo display phtml file in CMS page put this line
{{block class="Magento\Framework\View\Element\Template" name="test_block" template="{Vendor}_{Module}::test_block.phtml"}}
the same way in XML layout file you can use
<block class="Magento\Framework\View\Element\Template" name="test_block" template="{Vendor}_{Module}::test_block.phtml"/>
if you want to put it in phtml file