1

I've got a magento extension that is a custom blog ( Amasty ) . It doesn't use attributes of any kind to index the posts , but it's own custom table - blog_posts.

I'm not sure what is the best angel to take with this. If I could create an index of attributes that indexed the table? ( doesn't sound like a good idea )

I found a few posts about customising the extension

https://community.algolia.com/magento/doc/m1/customize-extension/ https://community.algolia.com/magento/doc/m1/indexing/

But I don't think they touch on what I need.

Thanks or your time.

1 Answer 1

0

Here's how I achieved what you're trying to gain via a custom module - it will require you to set up a collection of your blog table, or use the Amasty custom blog collection if you want. (My code was written for Algolia search 1.5.5 on Magento 1.9.2.4CE)

  public function indexProducts() {

      if (class_exists('AlgoliaSearch\Client', false) == false)
      {
          require_once Mage::getBaseDir('lib').'/AlgoliaSearch/Version.php';
          require_once Mage::getBaseDir('lib').'/AlgoliaSearch/AlgoliaException.php';
          require_once Mage::getBaseDir('lib').'/AlgoliaSearch/ClientContext.php';
          require_once Mage::getBaseDir('lib').'/AlgoliaSearch/Client.php';
          require_once Mage::getBaseDir('lib').'/AlgoliaSearch/Index.php';
          require_once Mage::getBaseDir('lib').'/AlgoliaSearch/PlacesIndex.php';
          require_once Mage::getBaseDir('lib').'/AlgoliaSearch/IndexBrowser.php';
      }

      $client = new \AlgoliaSearch\Client('YOUR_APP_ID', 'YOUR_ADMIN_API_KEY');

      // YOUR COLLECTION HERE OF BLOG POSTS...
      $collection = $this->getCollection();

      $results = array();
      $i = 0;

      foreach ($collection as $post) {

        $results[$i]['objectID'] = $post->getId();
        $results[$i]['title'] = $post->getTitle();
        $results[$i]['content'] = $post->getContent();

       $i++;

      }

      // index in algolia you want to add to
      $index = $client->initIndex('blog_index');
      $batch = $results;
      //print_R($batch);
      $index->addObjects($batch);

    }
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.