Skip to content

Commit 4103e06

Browse files
DOCs: update (#4349)
* Updated docs * Update README.md Co-authored-by: Colin Mollenhour <colin@mollenhour.com> * rtd * ignore CNAME in composer install * added git label * added blog posts (releases) * added blog posts (others) * spaces [ski ci] * removed blog posts * Updated modules section - step1: https://github.com/fballiano/awesome-openmage * internal links * minor title * minor change * link to DDEV windows guide --------- Co-authored-by: Colin Mollenhour <colin@mollenhour.com>
1 parent e47aa19 commit 4103e06

File tree

77 files changed

+1803
-571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1803
-571
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
/.phpstan.dist.neon export-ignore
2222
/.rector.php export-ignore
2323

24+
/CNAME export-ignore
25+
2426
/README.md export-ignore
2527

2628
# Enforce checkout with linux lf consistent over all platforms

.github/labeler.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
.github/**/*
66
]
77

8+
'git':
9+
- changed-files:
10+
- any-glob-to-any-file: [
11+
.gitattributes,
12+
.gitignore
13+
]
14+
815
'htaccess':
916
- changed-files:
1017
- any-glob-to-any-file: [

README.md

Lines changed: 3 additions & 359 deletions
Large diffs are not rendered by default.

docs/content/api/rest/resources/customers.md

Lines changed: 30 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
1-
\--- layout: v1x\_rest title: Customers --- JSON responses on this page contributed by Tim Reynolds
1+
# Customers
22

3-
* [REST API: Customers](#RESTAPI-Resource-Customers-RESTAPI-Customers)
4-
* [URI: /customers](#RESTAPI-Resource-Customers-URI--customers)
5-
* [HTTP Method: GET /customers](#RESTAPI-Resource-Customers-HTTPMethod-GET-customers)
6-
* [HTTP Method: POST /customers](#RESTAPI-Resource-Customers-HTTPMethod-POST-customers)
7-
* [HTTP Method: PUT /customers](#RESTAPI-Resource-Customers-HTTPMethod-PUT-customers)
8-
* [HTTP Method: DELETE /customers](#RESTAPI-Resource-Customers-HTTPMethod-DELETE-customers)
9-
* [REST API: Customer](#RESTAPI-Resource-Customers-RESTAPI-Customer)
10-
* [URI: /customers/:customerId](#RESTAPI-Resource-Customers-URI--customers--customerId)
11-
* [HTTP Method: GET /customers/:customerId](#RESTAPI-Resource-Customers-HTTPMethod-GET-customers--customerId)
12-
* [HTTP Method: POST /customers/:customerId](#RESTAPI-Resource-Customers-HTTPMethod-POST-customers--customerId)
13-
* [HTTP Method: PUT /customers/:customerId](#RESTAPI-Resource-Customers-HTTPMethod-PUT-customers--customerId)
14-
* [HTTP Method: DELETE /customers/:customerId](#RESTAPI-Resource-Customers-HTTPMethod-DELETE-customers--customerId)
15-
16-
## Customers
17-
18-
#### URI: /customers
3+
## URI: /customers
194

205
Allows you to create and retrieve customers.
216

@@ -164,9 +149,7 @@ If the customer was created successfully, we receive **Response HTTP Code** = 20
164149

165150
**Description**: Not allowed
166151

167-
## Customer
168-
169-
#### URI: /customers/:customerId
152+
## URI: /customers/:customerId
170153

171154
Allows you to manage existing customers.
172155

@@ -187,40 +170,39 @@ Allows you to manage existing customers.
187170
GET http://om.ddev.site/api/rest/customers/2
188171
```
189172

190-
**Response Body**:
173+
**Response body: XML**
191174

175+
```xml
192176
<?xml version="1.0"?>
193-
<magento\_api>
194-
<entity\_id>2</entity\_id>
195-
<website\_id>1</website\_id>
196-
<email>test@example.com</email>
197-
<group\_id>1</group\_id>
198-
<created\_at>2012-03-22 14:15:54</created\_at>
199-
<disable\_auto\_group\_change>1</disable\_auto\_group\_change>
200-
<created\_in>Default Store View</created\_in>
201-
<firstname>john</firstname>
202-
<lastname>Doe</lastname>
203-
<last\_logged\_in>2012-03-22 14:15:56</last\_logged\_in>
204-
</magento\_api>
205-
206-
**response example: json**
207-
208-
get [http://om.ddev.site/api/rest/customers/141](http://om.ddev.site/api/rest/customers)
177+
<magento_api>
178+
<entity_id>2</entity_id>
179+
<website_id>1</website_id>
180+
<email>test@example.com</email>
181+
<group_id>1</group_id>
182+
<created_at>2012-03-22 14:15:54</created_at>
183+
<disable_auto_group_change>1</disable_auto_group_change>
184+
<created_in>Default Store View</created_in>
185+
<firstname>john</firstname>
186+
<lastname>Doe</lastname>
187+
<last_logged_in>2012-03-22 14:15:56</last_logged_in>
188+
</magento_api>
189+
```
209190

210-
**response body**:
191+
**Response body: JSON**
211192

193+
```json
212194
{
213-
"entity\_id": "2",
214-
"website\_id": "1",
215-
"email": "test@example.com",
216-
"group\_id": "1",
217-
"created\_at": "2012-03-22 14:15:54",
218-
"disable\_auto\_group\_change": "1",
219-
"created\_in": "English",
220-
"firstname": "john",
221-
"lastname": "Doe"
195+
"entity_id": "2",
196+
"website_id": "1",
197+
"email": "test@example.com",
198+
"group_id": "1",
199+
"created_at": "2012-03-22 14:15:54",
200+
"disable_auto_group_change": "1",
201+
"created_in": "English",
202+
"firstname": "john",
203+
"lastname": "Doe"
222204
}
223-
205+
```
224206

225207
### HTTP Method POST
226208

docs/content/blog/.authors.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
authors:
2+
openmage_community:
3+
name: OpenMage
4+
description: Community
5+
avatar: https://avatars.githubusercontent.com/u/57708
6+
colinmollenhour:
7+
name: Colin Mollenhour
8+
description: Maintainer
9+
avatar: https://avatars.githubusercontent.com/u/38738
10+
fballiano :
11+
name: Fabrizio Balliano
12+
description: Contributor
13+
avatar: https://avatars.githubusercontent.com/u/909743
14+
Flyingmana:
15+
name: Daniel Fahlke
16+
description: Contributor
17+
avatar: https://avatars.githubusercontent.com/u/237319
18+
kiatng:
19+
name: Ng Kiat Siong
20+
description: Contributor
21+
avatar: https://avatars.githubusercontent.com/u/1106470
22+
real34:
23+
name: Pierre Martin
24+
description: Contributor
25+
avatar: https://avatars.githubusercontent.com/u/75968
26+
r-martins:
27+
name: Ricardo Martins
28+
description: Contributor
29+
avatar: https://avatars.githubusercontent.com/u/191149
30+
robertrogge:
31+
name: Robert Rogge
32+
description: Contributor
33+
avatar: https://avatars.githubusercontent.com/u/673488
34+
sreichel:
35+
name: Sven Reichel
36+
description: Contributor
37+
avatar: https://avatars.githubusercontent.com/u/5022236

docs/content/developers/guides/observer.md renamed to docs/content/blog/posts/guides/2022-08-17-observer.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
---
2+
title: Events & Observer
3+
draft: false
4+
date: 2022-08-17
5+
authors:
6+
- sreichel
7+
categories:
8+
- Guides
29
tags:
310
- Events
411
- Debug
@@ -9,6 +16,8 @@ tags:
916

1017
Quick overview how observers work.
1118

19+
<!-- more -->
20+
1221
## Event lookup
1322

1423
If you want to add custom logic for `customer_login` event, add in your `config.xml`.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: Dynamic block content
3+
draft: false
4+
date: 2023-01-09
5+
authors:
6+
- kiatng
7+
categories:
8+
- Guides
9+
tags:
10+
- CMS blocks
11+
---
12+
13+
# Dynamic block contents in category page
14+
15+
In _backend > Catalog > Manage Categories_, we can configure a category page and put it on the main menu. The page contents are rendered in
16+
17+
> app\design\frontend\base\default\template\catalog\category\view.phtml
18+
19+
If we want to render an HTML table in which its data are taken from the database, we would follow these steps:
20+
21+
<!-- more -->
22+
23+
## Create custom block
24+
25+
1. Create a custom block `mymodule/mytable` with template `mymodule/mytable.phtml`.
26+
2. Whitelist our block for rendering in the frontend: backend > System > Permissions > Blocks
27+
3. Create a CMS static block: backend > CMS > Static Blocks and set the _Content_ to render from our block with this directive:
28+
```html
29+
{{block type="mymodule/mytable" template="mymodule/mytable.phtml"}}
30+
```
31+
4. Create a subcategory: backend > Catalog > Manage Categories > Add a subcategory and in the _Display Setings_ tab, set the category attribute _Display Mode_ to _Static block only_ and _CMS Block_ pointing to our block.
32+
33+
Voila, the HTML table is rendered under the menu we just created. However, every time the table in the database is updated, and because CMS blocks rendering are taken from the cache, we would need to refresh the cache.
34+
35+
## Render block dynamically
36+
37+
What if the table is constantly being updated, or there is an expiry condition on some data which shouldn't be included? In which case, we would want to render the HTML table dynamically. It's actually quite easy to do:
38+
39+
1. In the subcategory page in backend, set the _Description_ to this:
40+
```html
41+
{{block type="mymodule/mytable" template="mymodule/mytable.phtml"}}
42+
```
43+
2. Continue on to the _Display Setings_ tab and set the _CMS Block_ to _Please select a static block ..._.
44+
3. In our config file, either in the module `etc/config.xml` or in the `local.xml`, insert the following:
45+
46+
```xml
47+
<config>
48+
<global>
49+
<catalog>
50+
<content>
51+
<tempate_filter>cms/template_filter</tempate_filter> <!-- Note the typo on template must remain as "tempate". -->
52+
</content>
53+
</catalog>
54+
</global>
55+
</config>
56+
```
57+
58+
That's it, the table is now rendered dynamically. There 's no need to create the CMS static block.
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
title: Customize Your OpenMage
3+
draft: false
4+
date: 2023-08-17
5+
authors:
6+
- colinmollenhour
7+
categories:
8+
- Guides
9+
tags:
10+
- Composer
11+
- Patches
12+
- Vendor
13+
---
14+
15+
# Customize Your OpenMage
16+
17+
When working on OpenMage or any complex PHP project, you might come across issues that require patches to be applied to third-party packages or libraries.
18+
These patches may be fixes or features for core code that you need to use immediately but have not yet been merged or formally released for any number of reasons.
19+
20+
In this blog post, we'll explore the benefits of using privately maintained patches and how to use Composer and the `cweagans/composer-patches` dependency to maintain
21+
your own set of patches as well as how to generate patches.
22+
23+
<!-- more -->
24+
25+
## Benefits of Privately Maintained Patches
26+
27+
1. Customization - Customize third-party packages or libraries to meet the specific needs of your project. This is especially useful if you need to modify functionality that is impossible to do without modifying core code or fix bugs that are not yet addressed by the package maintainers.
28+
2. Security - By maintaining your own patches, you can ensure that any security vulnerabilities are addressed as soon as they are discovered, without having to wait for the package maintainers to release an update.
29+
3. Maintainability - Privately maintained patches can help ensure your patches are organized and automatically re-applied to the core code so they don't get accidentally clobbered when updating project dependencies.
30+
31+
## Using Composer and `cweagans/composer-patches` Dependency
32+
33+
Composer is a dependency manager for PHP that allows you to easily manage third-party packages and libraries in your project. However, using the `cweagans/composer-patches` package
34+
(documentation [here](https://github.com/cweagans/composer-patches/blob/1.x/README.md)) you can also have Composer apply private patches over public dependencies. You simply define the patches in your `composer.json` file and they will be automatically applied to the
35+
packages or libraries that you specify when a Composer updates dependencies (`install` or `update`).
36+
37+
Here's an example `composer.json` file with a patch defined:
38+
39+
```json
40+
{
41+
"require": {
42+
"vendor/package": "1.0.0"
43+
},
44+
"extra": {
45+
"patches": {
46+
"vendor/package": {
47+
"Fix Bug #1234": "patches/fix-bug-1234.patch"
48+
}
49+
}
50+
}
51+
}
52+
```
53+
54+
In this example, we're requiring the `vendor/package` package at version `1.0.0`, and applying a patch named "Fix Bug \#1234" located in the `patches/fix-bug-1234.patch` file.
55+
56+
To apply the patch, simply run `composer update` and Composer will apply the patch and maintain the state of whether the patch has been applied or not.
57+
58+
## Generating patch files
59+
60+
There are many ways to do this, but here are a few common ones:
61+
62+
### Github Pull Requests
63+
64+
If a Github PR already contains the code changes you need, simply download a patch file from Github by appending `.patch` to the PR url. You gotta love Github!
65+
66+
For example, the patch URL for PR #3146 is: `https://github.com/OpenMage/magento-lts/pull/3146.patch`. This url will result in a redirect so download it with your
67+
browser or a client that follows redirects (Location header) such as `wget` or `curl -L`.
68+
69+
```
70+
mkdir -p patches
71+
echo -e "Order deny,allow\nDeny from all\n" > patches/.htaccess
72+
curl -L https://github.com/OpenMage/magento-lts/pull/3146.patch -o var/patches/3146_Add-form-key-validation-to-Contacts-form.patch
73+
```
74+
75+
Note, you can also have the patch downloaded at runtime by defining it as a url instead of a local path.
76+
77+
```json
78+
{
79+
"...": "...",
80+
"extra": {
81+
"patches": {
82+
"openmage/magento-lts": {
83+
"Added form key validation to Contacts form #3146": "https://github.com/OpenMage/magento-lts/pull/3146.patch"
84+
}
85+
}
86+
}
87+
}
88+
```
89+
90+
If it doesn't apply cleanly, apply the patch using `git apply` and fix the conflicts and then output the changes as a local patch file using one of the methods below.
91+
92+
### symplify/vendor-patches
93+
94+
If you are using OpenMage as a project dependency, you can use `symplify/vendor-patches` to generate a patch file easily. This tool automatically
95+
updates your composer.json for you. Note, in the case of modifying OpenMage core code installed as a project dependency you will need to modify the
96+
files in the "vendor" directory rather than the `magento-root-dir` directory (e.g. "htdocs").
97+
98+
Here is an example generating patches for `app/Mage.php`:
99+
100+
```sh
101+
composer require symplify/vendor-patches --dev
102+
cp vendor/app/Mage.php vendor/app/Mage.php.old
103+
# modify app/Mage.php to your liking
104+
vendor/bin/vendor-patches generate
105+
composer install
106+
```
107+
108+
### Git with dirty working copy
109+
110+
If you have local changes on a git working copy you can simply use `git diff > patches/my-changes.patch`.
111+
112+
Use `git diff --cached` instead to export just the staged changes.
113+
114+
### Git commits
115+
116+
You can generate a patch from a branch or commit or range of commits using `git format-patch` or `git diff`. See the `--help` usage for more info but here are some examples:
117+
118+
To get a single patch with the changes from the `some-feature` branch:
119+
120+
```sh
121+
git format-patch origin/main...some-feature --stdout > patches/some-feature.patch
122+
```
123+
124+
Notice the three `...` which gets all changes as one patch. If you used `..` you would get one file per commit.
125+
126+
Use `git show <commit>` to show a single commit or `git diff <base>...<commit>` to get all changes between two commits. Consult the interwebs for more info.
127+
128+
## Testing patches
129+
130+
Use `git apply` or `patch` to test applying the patches to your working copy or just go for it with `composer install`.
131+
132+
Use `composer update --lock` to save the state of the applied patches to your `composer.lock` file.
133+
134+
Give it a try and see how privately maintained patches can benefit your project!

0 commit comments

Comments
 (0)