By Namal Dissanayake for Ajalan's case study.
- Create magento project
composer create-project --repository=https://repo.magento.com/ magento/project-community-edition- Create a DB, setup virtual hosts and setup RabbitMQ.
- Navigate to project directory inside the cloned repository.
- Install composer packages.
composer install- Install Magento using below command
php bin/magento setup:install --base-url=http://magento2.local/ --base-url-secure=https://magento2.local/ \
--db-host=localhost --db-name=db_name --db-user=db_user --db-password=db_pw \
--admin-firstname=FirstName --admin-lastname=LastName --admin-email=john.doe@example.com \
--admin-user=admin_uname --admin-password=admin_pword --use-rewrites=1 --backend-frontname=admin \
--amqp-host="localhost" --amqp-port="5672" --amqp-user="rabbitmq_user" --amqp-password="rabbitmq_pword" --amqp-virtualhost="/"- Run setup upgrade.
php bin/magento setup:upgradeAs requested, custom module have been developed for install using composer package manager. Respository only containing the module have been submited to packagist.org. So you can use below command to install the package to your project.
composer require ajlan/module-custom-catalogIt should add a "CustomCatalog" menu on PRODUCTS section
When we click on CustomCatalog link it should list all added products. And it should also have filtering options.
We should be able to add/edit products.
In the screenshots we have many fields. Just need to cover these fields. ProductID,SKU,CopyWriteInfo,VPN for this case.
- ProductID (a unique identifier of a product, string) \ scope = global
- CopyWriteInfo (copy write information, text) \ scope = store
- VPN ( Vendor Product Number, string) \ scope = global
- SKU( string) \ scope = global
You just need to add above 4 fields to be listed, added and edited. Admin should be able to search with particular VPN and perform CRUD operations.
Below custom endpoints developed as per the requirement specified. On case 2.2.2, I have altered payload to match with magento default payload for a product save.
Endpoint: rest/V1/product/getByVPN/:VPN
Method: GET
Endpoint: rest/V1/product/update
Method: PUT
Sample payload:
Note: The payload here is bit different than the provided example since I used Magento's product entity
{
"product": {
"sku": "product-sku",
"name": "Product Name",
"price": 99,
"status": 1,
"visibility": 4,
"type_id": "simple",
"attribute_set_id": 4,
"custom_attributes": [
{
"attribute_code": "description",
"value": "product description"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "ProductID",
"value": "PUID_1"
},
{
"attribute_code": "CopyWriteInfo",
"value": "Copy Write Information"
},
{
"attribute_code": "VPN",
"value": "VPN1"
}
]
}
}

