Skip to content
  1. Extras
  2. ResourceGrabber

Quick start

You need MODX 2.3 or higher and PHP 5.4 or higher.

Description

ResourceGrabber - Resource Grabber. The component implements parsing data from a URL.

ResourceGrabber

Features:

  • Integration with miniShop2 (creating/updating products)
  • Integration with CurrencyRate. (price modification)
  • Integration with msOptionSeller. (setting the option Store miniShop2 product)

Demo site

Demo site available at http://s14332.h10.modhost.pro.

Login and password for the manager: test

Installation

For testing you can use our hosting; these extras can be selected when creating a site.

Installation

Settings

  • working_templates — list the template IDs for which to enable the feature.

Snippets

Create a snippet to parse data. A sample snippet for the aliexpress site is in core/components/resourcegrabber/snippets/aliexpress/product.inc.

You can create a snippet for your needs following this example.

Cron

To update resources you can use the cron script; an example is in core/components/resourcegrabber/cron/update.php.

php
<?php

// update all miniShop2 products older than 5 days

$q = $modx->newQuery('GrabData');
$q->setClassAlias('Grab');
$q->innerJoin('msProduct', 'Product', 'Grab.id = Product.id');
$q->where(array(
  'Grab.timestamp:<'  => $ResourceGrabber->changeDate(time(), '5d', true),
  'Product.deletedon' => false,
));

$idx = 0;
/** @var GrabData $d */
foreach ($modx->getCollection('GrabData', $q) as $d) {
  if ($data = $d->grab()) {
    $d->set('data', $data);
    $d->save();
    $idx++;
  }
}

$modx->log(modX::LOG_LEVEL_ERROR, "Process total: " . $idx);