Influencer marketing for ecommerce. For more information go to https://grin.co/
- composer config repositories.grin vcs https://github.com/grininc/grin-magento-module
- composer require grin/module
- bin/magento setup:upgrade
- bin/magento setup:di:compile
- bin/magento setup:static-content:deploy
- bin/magento cache:flush
- composer update grin/module
- bin/magento setup:upgrade
- bin/magento setup:di:compile
- bin/magento setup:static-content:deploy
- bin/magento cache:flush
This repository includes a GitHub Actions workflow (.github/workflows/deploy-module-staging.yml) that automates deployment of the latest code from the main branch to staging by connecting via SSH using stored credentials, updating the module via Composer, and running required Magento deployment commands.
- Grin uses composer to provide their extension to the end customer.
- The extension follows semver principles.
- Once the new implementation of Grin_Affiliate is ready to be installed and tested it will get version 2.0.x.
- If an end-user has the previous version of the extension installed via https://docs.magento.com/user-guide/v2.3/system/web-setup-wizard.html or manually in app/code, the extension must be removed before new installation.
- Issue: I updated the extension, but it seems like the old version is installed despite the fact that in the compose.lock file I see the updated version of the extension.
Possible solution: the extension uses a DB queue, which is run in shadow mode. So it might be that you did not kill the old process after the installation.
Try to execute ps -aux | grep grin_module_webhook
and kill the process if any.
- Issue: I am using Magento cloud instance and it seems like the 'webhook_grin_module' is not working.
Possible solution: in this case, according to Magento documentation, you need to make sure that the queue job is added into the /app/etc/env.php file like so:
...
'cron_consumers_runner' => [
'cron_run' => false,
'max_messages' => 20000,
'consumers' => [
'consumer1',
'consumer2',
'grin_module_webhook',
...
]
],
...
This module uses Docker for local development. Follow these steps to set up your development environment:
- Docker
- Docker Compose
- PHP 8.1 or higher
- Composer
The development environment uses custom ports to avoid conflicts with other services:
Service | Default Port | Development Port |
---|---|---|
Web Server | 80 | 8081 |
HTTPS | 443 | 8443 |
MySQL | 3306 | 3307 |
Redis | 6379 | 6380 |
OpenSearch | 9200 | 9201 |
RabbitMQ | 5672 | 5673 |
Mailcatcher | 1025 | 1026 |
These ports are automatically configured during setup to avoid conflicts with other services like app.grin.co
.
-
Magento Marketplace Credentials:
- Go to Magento Marketplace Access Keys
- Create a new access key if you don't have one
- Note down your Public Key and Private Key
-
GitHub Token:
- Go to GitHub Personal Access Tokens
- Create a new token with
repo
scope - Note down your token
-
Copy the auth template file:
cp scripts/magento-auth.template scripts/magento-auth.env
-
Edit
scripts/magento-auth.env
and add your credentials:MAGENTO_MARKETPLACE_PUBLIC_KEY=your_public_key MAGENTO_MARKETPLACE_PRIVATE_KEY=your_private_key GITHUB_TOKEN=your_github_token
-
First-time setup only: Run the setup script:
./scripts/setup-first-time.sh
This script will:
- Set up a local Magento installation using Docker
- Configure the necessary ports and hosts
- Mount your module code into the Magento installation
- Enable and configure the module
- Start the Docker containers
Note: This script should only be run once during the initial setup. It already starts the containers, so there's no need to run
start-env.sh
after it. -
For subsequent development sessions: Start the development environment:
./scripts/start-env.sh
- The module code is mounted into the Magento installation, so any changes you make to the code will be immediately reflected
- The Magento installation is available at
https://magento.grin.co.test:8443
- Admin panel is available at
https://magento.grin.co.test:8443/admin
- Username:
admin
- Password:
admin123
- Username:
To populate your Magento store with sample products, categories, and other content, you can use the provided script:
./scripts/install-sample-data.sh
This script will:
- Set Magento to developer mode
- Install the sample data
- Run setup upgrade
- Clean and flush the cache
After running this script, you'll have:
- Sample products to test with
- Categories
- Customer accounts
- Sales rules (including coupon codes)
- And more
This makes it easier to test functionality like coupon codes and other features that require store content.
When you modify plugin code or other PHP files:
- Clear the Magento cache:
cd .docker-magento bin/clinotty bin/magento cache:clean bin/clinotty bin/magento cache:flush
- Refresh your browser page
Note: In developer mode, you don't need to run
setup:di:compile
after every change. However, if you're in production mode, you would need to run it.
If you encounter any issues:
-
Check if the module is properly enabled:
cd .docker-magento bin/clinotty bin/magento module:status Grin_Module
-
If the module is disabled, try re-enabling it:
cd .docker-magento bin/clinotty bin/magento module:enable Grin_Module --force bin/clinotty bin/magento setup:upgrade bin/clinotty bin/magento cache:flush
-
Check the Magento logs in the container:
cd .docker-magento bin/clinotty tail -f var/log/system.log
To run unit tests for this module, use the provided script:
./scripts/run-tests.sh
- This will run all tests in the
Test
directory.
To run a specific test file, provide the relative path from the module root:
./scripts/run-tests.sh Test/Unit/Plugin/Magento/SalesRule/Model/RulesApplier/ValidateByTokenTest.php
The script will automatically execute the tests inside the Docker container using the correct environment.
To check your code against Magento's coding standards, use the provided script:
./scripts/run-coding-standard.sh
- This will check all files in the module against Magento's coding standards.
- Generated code and Docker-related files are automatically ignored.
To check a specific file, provide the relative path from the module root:
./scripts/run-coding-standard.sh Test/Unit/Plugin/Magento/SalesRule/Model/RulesApplier/ValidateByTokenTest.php
The script will:
- Run the coding standard check inside the Docker container
- Generate a detailed report
- Display any warnings or errors found
If you want to completely remove your local Magento development environment, follow these steps:
-
Stop and remove Docker containers and volumes:
docker compose -f $HOME/.docker-magento/compose.yaml down -v
This will stop and remove all containers and associated Docker volumes for your Magento environment.
-
Remove the Docker Magento workspace directory:
rm -rf $HOME/.docker-magento
This will delete all files related to the local Docker Magento environment, including configuration, data, and any persistent files.
Note: This process will remove your local Magento instance, database, and all related data. Only do this if you are sure you want a full reset.
This local development setup is based on markshust/docker-magento.