PHPackages                             rocketweb/module-content-update - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rocketweb/module-content-update

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

rocketweb/module-content-update
===============================

Module for creating and updating static content using data scripts.

1.1.0(7y ago)214GPL-3.0PHP

Since Feb 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/rocketweb-fed/module-content-update)[ Packagist](https://packagist.org/packages/rocketweb/module-content-update)[ RSS](/packages/rocketweb-module-content-update/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

RocketWeb\_ContentUpdate
========================

[](#rocketweb_contentupdate)

Module takes care of creating and updating static content using data scripts.

Installation
------------

[](#installation)

Install using Composer

```
$ composer require rocketweb/module-content-update
$ bin/magento module:enable RocketWeb_ContentUpdate
$ bin/magento setup:upgrade

```

To install manually download the module contents into app/code/RocketWeb/ContentUpdate

Configuration
-------------

[](#configuration)

Create new module ***ProjectNamespace*/ContentUpdate** in the `app/code` directory using steps below:

> Replace *ProjectNamespace* in the steps below with project or vendor namespace

1. Create `composer.json`

```
{
    "name": "projectNamespace/module-content-update",
    "description": "Module for creating and updating static content using data scripts.",
    "type": "magento2-module",
    "version": "1.0.0",
    "license": "GPL-3.0",
    "authors": [
        {
            "name": "Company Name",
            "email": "company@email.com"
        }
    ],
    "autoload": {
        "files": [
            "registration.php"
        ],
        "psr-4": {
            "Projectnamespace\\UpgradeData\\": ""
        }
    }
}
```

2. Create `registration.php`

```

```

4. Clone `vendor/rocketweb/module-content-update/Setup/UpgradeData` to `app/code/ProjectNamespace/ContentUpdate/Setup/UpgradeData.php`
5. Open `Setup/UpgradeData.php` and replace

```
namespace RocketWeb\ContentUpdate\Setup

```

with

```
namespace ProjectNamespace\ContentUpdate\Setup

```

6. Clear example functions in UpgradeData.php and add your own (see reference in the next section)
7. Run

```
bin/magento module:enable ProjectNamespace/ContentUpdate
bin/magento setup:upgrade

```

---

Usage
-----

[](#usage)

### Adding update functions and triggering them

[](#adding-update-functions-and-triggering-them)

1. Open `ProjectNamespace_ContentUpdate/etc/module.xml`
2. Change setup\_version attribute from x.y.z to x.y.z++ eg. 1.0.9 to 1.0.10
3. Open `ProjectNamespace_ContentUpdate/Setup/UpgradeData.php`
4. Scroll to the bottom of the file
5. Before the closing braces add your function using a unique name (createUIPage). Use instructions below as a reference for creating and updating various elements.
6. When done creating function scroll up and find $setup-&gt;endSetup();
7. The last entry before that line should look something like

```
if (version_compare($context->getVersion(), '1.0.9') < 0) {
            $this->someFunction($helperSetup);
        }

```

8. Duplicate this entry and update both setup version number (to match the one from module.xml) and function name (to the recently created one)
9. When done save the file and run `bin/magento setup:upgrade`
10. Go to the page/block you created to confirm it's working properly

> If you need to revert module's setup\_version number while making adjustments you can do that by modifying a database entry in setup\_module table. Make sure to revert both schema\_version in data\_version before running `magento setup:uprade`. Note that you can only change it via db until you commit.

### Update functions

[](#update-functions)

#### Create a new CMS page

[](#create-a-new-cms-page)

```
public function createNewCmsPage($helperSetup)
{
    $storeId = $helperSetup->getStoreId('admin');
    $stores = [$storeId]; // Or $stores = = [$storeId, .. ]; to assign the page to more than one store

    $content =
