# how can i extend engine/shopware/core/sExport.php in my plugin?

**URL:** <https://forum.shopware.com/t/how-can-i-extend-engine-shopware-core-sexport-php-in-my-plugin/36968>\
**Category:** Programmierung\
**Created:** [24. Mai 2016 um 10:54 UTC](https://forum.shopware.com/t/how-can-i-extend-engine-shopware-core-sexport-php-in-my-plugin/36968 "2016-05-24T10:54:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alirizvi](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@alirizvi](https://forum.shopware.com/u/alirizvi)\
**Post date:** [24. Mai 2016 um 10:54 UTC](https://forum.shopware.com/t/how-can-i-extend-engine-shopware-core-sexport-php-in-my-plugin/36968/1 "2016-05-24T10:54:57Z")

</div>

I have an additional field attr21 in table s\_articles\_attributes.

In order to export it, i need to add this field to **sCreateSql() function** inside engine/shopware/core/sExport.php as follows

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $sql=" …

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d.weight,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d.position,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at.attr1, at.attr2, at.attr3, at.attr4, at.attr5, at.attr6, at.attr7, at.attr8, at.attr9, at.attr10,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at.attr11, at.attr12, at.attr13, at.attr14, at.attr15, at.attr16, at.attr17, at.attr18, at.attr19, at.attr20, **at.attr21,**

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s.name as supplier,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; u.unit

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; …";

But the problem is i cant add it directly over here, so I need to extend sExport.php class and add attr21 through my plugin?

how can i extend sExport.php?

---

<div class="post-metadata">

**Author:** ![steinsoftware](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@steinsoftware](https://forum.shopware.com/u/steinsoftware)\
**Post date:** [24. Mai 2016 um 12:16 UTC](https://forum.shopware.com/t/how-can-i-extend-engine-shopware-core-sexport-php-in-my-plugin/36968/2 "2016-05-24T12:16:48Z")

</div>

Inside Install use after hook.

Than something like

```
public function afterCoreExportCreateSql(Enlight_Hook_HookArgs $args){
$sql = $args->getReturn();

//modify $sql

$args->setReturn($sql);
}

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![alirizvi](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@alirizvi](https://forum.shopware.com/u/alirizvi)\
**Post date:** [24. Mai 2016 um 12:59 UTC](https://forum.shopware.com/t/how-can-i-extend-engine-shopware-core-sexport-php-in-my-plugin/36968/3 "2016-05-24T12:59:45Z")

</div>

Thanks alot Steinsoftware,

just one more thing that against which event should i register afterCoreExportCreateSql that is:

private function registerEvents()  
{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this-\>subscribeEvent(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‘???’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ’ afterCoreExportCreateSql ’  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );

.

.

.}

---

<div class="post-metadata">

**Author:** ![steinsoftware](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@steinsoftware](https://forum.shopware.com/u/steinsoftware)\
**Post date:** [24. Mai 2016 um 13:21 UTC](https://forum.shopware.com/t/how-can-i-extend-engine-shopware-core-sexport-php-in-my-plugin/36968/4 "2016-05-24T13:21:29Z")

</div>

use an after hook

‚sExport::sCreateSql::after‘

---

<div class="post-metadata">

**Author:** ![alirizvi](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@alirizvi](https://forum.shopware.com/u/alirizvi)\
**Post date:** [24. Mai 2016 um 13:44 UTC](https://forum.shopware.com/t/how-can-i-extend-engine-shopware-core-sexport-php-in-my-plugin/36968/5 "2016-05-24T13:44:50Z")

</div>

wow great! thanks a ton ![Thumb-Up](http://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/thumb-up.png "Thumb-Up")
