Complex classes like ProductBunchProcessor often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ProductBunchProcessor, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 49 | class ProductBunchProcessor implements ProductBunchProcessorInterface |
||
| 50 | { |
||
| 51 | |||
| 52 | /** |
||
| 53 | * A PDO connection initialized with the values from the Doctrine EntityManager. |
||
| 54 | * |
||
| 55 | * @var \TechDivision\Import\Connection\ConnectionInterface |
||
| 56 | */ |
||
| 57 | protected $connection; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * The repository to access EAV attribute option values. |
||
| 61 | * |
||
| 62 | * @var \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface |
||
| 63 | */ |
||
| 64 | protected $eavAttributeOptionValueRepository; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * The repository to access EAV attributes. |
||
| 68 | * |
||
| 69 | * @var \TechDivision\Import\Repositories\EavAttributeRepositoryInterface |
||
| 70 | */ |
||
| 71 | protected $eavAttributeRepository; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * The action for product CRUD methods. |
||
| 75 | * |
||
| 76 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 77 | */ |
||
| 78 | protected $productAction; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * The action for product varchar attribute CRUD methods. |
||
| 82 | * |
||
| 83 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 84 | */ |
||
| 85 | protected $productVarcharAction; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * The action for product text attribute CRUD methods. |
||
| 89 | * |
||
| 90 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 91 | */ |
||
| 92 | protected $productTextAction; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * The action for product int attribute CRUD methods. |
||
| 96 | * |
||
| 97 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 98 | */ |
||
| 99 | protected $productIntAction; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * The action for product decimal attribute CRUD methods. |
||
| 103 | * |
||
| 104 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 105 | */ |
||
| 106 | protected $productDecimalAction; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * The action for product datetime attribute CRUD methods. |
||
| 110 | * |
||
| 111 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 112 | */ |
||
| 113 | protected $productDatetimeAction; |
||
| 114 | |||
| 115 | /** |
||
| 116 | * The action for product website CRUD methods. |
||
| 117 | * |
||
| 118 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 119 | */ |
||
| 120 | protected $productWebsiteAction; |
||
| 121 | |||
| 122 | /** |
||
| 123 | * The action for category product relation CRUD methods. |
||
| 124 | * |
||
| 125 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 126 | */ |
||
| 127 | protected $categoryProductAction; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * The action for stock item CRUD methods. |
||
| 131 | * |
||
| 132 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 133 | */ |
||
| 134 | protected $stockItemAction; |
||
| 135 | |||
| 136 | /** |
||
| 137 | * The action for URL rewrite CRUD methods. |
||
| 138 | * |
||
| 139 | * @var \TechDivision\Import\Actions\ActionInterface |
||
| 140 | */ |
||
| 141 | protected $urlRewriteAction; |
||
| 142 | |||
| 143 | /** |
||
| 144 | * The repository to load the products with. |
||
| 145 | * |
||
| 146 | * @var \TechDivision\Import\Product\Repositories\ProductRepositoryInterface |
||
| 147 | */ |
||
| 148 | protected $productRepository; |
||
| 149 | |||
| 150 | /** |
||
| 151 | * The repository to load the product website relations with. |
||
| 152 | * |
||
| 153 | * @var \TechDivision\Import\Product\Repositories\ProductWebsiteRepositoryInterface |
||
| 154 | */ |
||
| 155 | protected $productWebsiteRepository; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * The repository to load the product datetime attribute with. |
||
| 159 | * |
||
| 160 | * @var \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface |
||
| 161 | */ |
||
| 162 | protected $productDatetimeRepository; |
||
| 163 | |||
| 164 | /** |
||
| 165 | * The repository to load the product decimal attribute with. |
||
| 166 | * |
||
| 167 | * @var \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface |
||
| 168 | */ |
||
| 169 | protected $productDecimalRepository; |
||
| 170 | |||
| 171 | /** |
||
| 172 | * The repository to load the product integer attribute with. |
||
| 173 | * |
||
| 174 | * @var \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface |
||
| 175 | */ |
||
| 176 | protected $productIntRepository; |
||
| 177 | |||
| 178 | /** |
||
| 179 | * The repository to load the product text attribute with. |
||
| 180 | * |
||
| 181 | * @var \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface |
||
| 182 | */ |
||
| 183 | protected $productTextRepository; |
||
| 184 | |||
| 185 | /** |
||
| 186 | * The repository to load the product varchar attribute with. |
||
| 187 | * |
||
| 188 | * @var \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface |
||
| 189 | */ |
||
| 190 | protected $productVarcharRepository; |
||
| 191 | |||
| 192 | /** |
||
| 193 | * The repository to load the category product relations with. |
||
| 194 | * |
||
| 195 | * @var \TechDivision\Import\Product\Repositories\CategoryProductRepositoryInterface |
||
| 196 | */ |
||
| 197 | protected $categoryProductRepository; |
||
| 198 | |||
| 199 | /** |
||
| 200 | * The repository to load the stock item with. |
||
| 201 | * |
||
| 202 | * @var \TechDivision\Import\Product\Repositories\StockItemRepositoryInterface |
||
| 203 | */ |
||
| 204 | protected $stockItemRepository; |
||
| 205 | |||
| 206 | /** |
||
| 207 | * The assembler to load the product attributes with. |
||
| 208 | * |
||
| 209 | * @var \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface |
||
| 210 | */ |
||
| 211 | protected $productAttributeAssembler; |
||
| 212 | |||
| 213 | /** |
||
| 214 | * The raw entity loader instance. |
||
| 215 | * |
||
| 216 | * @var \TechDivision\Import\Loaders\LoaderInterface |
||
| 217 | */ |
||
| 218 | protected $rawEntityLoader; |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Initialize the processor with the necessary assembler and repository instances. |
||
| 222 | * |
||
| 223 | * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection to use |
||
| 224 | * @param \TechDivision\Import\Product\Repositories\ProductRepositoryInterface $productRepository The product repository to use |
||
| 225 | * @param \TechDivision\Import\Product\Repositories\ProductWebsiteRepositoryInterface $productWebsiteRepository The product website repository to use |
||
| 226 | * @param \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface $productDatetimeRepository The product datetime repository to use |
||
| 227 | * @param \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface $productDecimalRepository The product decimal repository to use |
||
| 228 | * @param \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface $productIntRepository The product integer repository to use |
||
| 229 | * @param \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface $productTextRepository The product text repository to use |
||
| 230 | * @param \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface $productVarcharRepository The product varchar repository to use |
||
| 231 | * @param \TechDivision\Import\Product\Repositories\CategoryProductRepositoryInterface $categoryProductRepository The category product repository to use |
||
| 232 | * @param \TechDivision\Import\Product\Repositories\StockItemRepositoryInterface $stockItemRepository The stock item repository to use |
||
| 233 | * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository The EAV attribute option value repository to use |
||
| 234 | * @param \TechDivision\Import\Repositories\EavAttributeRepositoryInterface $eavAttributeRepository The EAV attribute repository to use |
||
| 235 | * @param \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface $eavEntityTypeRepository The EAV entity type repository to use |
||
| 236 | * @param \TechDivision\Import\Actions\ActionInterface $categoryProductAction The category product action to use |
||
| 237 | * @param \TechDivision\Import\Actions\ActionInterface $productDatetimeAction The product datetime action to use |
||
| 238 | * @param \TechDivision\Import\Actions\ActionInterface $productDecimalAction The product decimal action to use |
||
| 239 | * @param \TechDivision\Import\Actions\ActionInterface $productIntAction The product integer action to use |
||
| 240 | * @param \TechDivision\Import\Actions\ActionInterface $productAction The product action to use |
||
| 241 | * @param \TechDivision\Import\Actions\ActionInterface $productTextAction The product text action to use |
||
| 242 | * @param \TechDivision\Import\Actions\ActionInterface $productVarcharAction The product varchar action to use |
||
| 243 | * @param \TechDivision\Import\Actions\ActionInterface $productWebsiteAction The product website action to use |
||
| 244 | * @param \TechDivision\Import\Actions\ActionInterface $stockItemAction The stock item action to use |
||
| 245 | * @param \TechDivision\Import\Actions\ActionInterface $urlRewriteAction The URL rewrite action to use |
||
| 246 | * @param \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface $productAttributeAssembler The assembler to load the product attributes with |
||
| 247 | * @param \TechDivision\Import\Loaders\LoaderInterface $rawEntityLoader The raw entity loader instance |
||
| 248 | */ |
||
| 249 | public function __construct( |
||
| 302 | |||
| 303 | /** |
||
| 304 | * Set's the raw entity loader instance. |
||
| 305 | * |
||
| 306 | * @param \TechDivision\Import\Loaders\LoaderInterface $rawEntityLoader The raw entity loader instance to set |
||
| 307 | * |
||
| 308 | * @return void |
||
| 309 | */ |
||
| 310 | public function setRawEntityLoader(LoaderInterface $rawEntityLoader) |
||
| 314 | |||
| 315 | /** |
||
| 316 | * Return's the raw entity loader instance. |
||
| 317 | * |
||
| 318 | * @return \TechDivision\Import\Loaders\LoaderInterface The raw entity loader instance |
||
| 319 | */ |
||
| 320 | public function getRawEntityLoader() |
||
| 324 | |||
| 325 | /** |
||
| 326 | * Set's the passed connection. |
||
| 327 | * |
||
| 328 | * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection to set |
||
| 329 | * |
||
| 330 | * @return void |
||
| 331 | */ |
||
| 332 | public function setConnection(ConnectionInterface $connection) |
||
| 336 | |||
| 337 | /** |
||
| 338 | * Return's the connection. |
||
| 339 | * |
||
| 340 | * @return \TechDivision\Import\Connection\ConnectionInterface The connection instance |
||
| 341 | */ |
||
| 342 | public function getConnection() |
||
| 346 | |||
| 347 | /** |
||
| 348 | * Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO |
||
| 349 | * object instance are not committed until you end the transaction by calling ProductProcessor::commit(). |
||
| 350 | * Calling ProductProcessor::rollBack() will roll back all changes to the database and return the connection |
||
| 351 | * to autocommit mode. |
||
| 352 | * |
||
| 353 | * @return boolean Returns TRUE on success or FALSE on failure |
||
| 354 | * @link http://php.net/manual/en/pdo.begintransaction.php |
||
| 355 | */ |
||
| 356 | public function beginTransaction() |
||
| 360 | |||
| 361 | /** |
||
| 362 | * Commits a transaction, returning the database connection to autocommit mode until the next call to |
||
| 363 | * ProductProcessor::beginTransaction() starts a new transaction. |
||
| 364 | * |
||
| 365 | * @return boolean Returns TRUE on success or FALSE on failure |
||
| 366 | * @link http://php.net/manual/en/pdo.commit.php |
||
| 367 | */ |
||
| 368 | public function commit() |
||
| 372 | |||
| 373 | /** |
||
| 374 | * Rolls back the current transaction, as initiated by ProductProcessor::beginTransaction(). |
||
| 375 | * |
||
| 376 | * If the database was set to autocommit mode, this function will restore autocommit mode after it has |
||
| 377 | * rolled back the transaction. |
||
| 378 | * |
||
| 379 | * Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition |
||
| 380 | * language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit |
||
| 381 | * COMMIT will prevent you from rolling back any other changes within the transaction boundary. |
||
| 382 | * |
||
| 383 | * @return boolean Returns TRUE on success or FALSE on failure |
||
| 384 | * @link http://php.net/manual/en/pdo.rollback.php |
||
| 385 | */ |
||
| 386 | public function rollBack() |
||
| 390 | |||
| 391 | /** |
||
| 392 | * Set's the repository to access EAV attribute option values. |
||
| 393 | * |
||
| 394 | * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository The repository to access EAV attribute option values |
||
| 395 | * |
||
| 396 | * @return void |
||
| 397 | */ |
||
| 398 | public function setEavAttributeOptionValueRepository(EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository) |
||
| 402 | |||
| 403 | /** |
||
| 404 | * Return's the repository to access EAV attribute option values. |
||
| 405 | * |
||
| 406 | * @return \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface The repository instance |
||
| 407 | */ |
||
| 408 | public function getEavAttributeOptionValueRepository() |
||
| 412 | |||
| 413 | /** |
||
| 414 | * Set's the repository to access EAV attributes. |
||
| 415 | * |
||
| 416 | * @param \TechDivision\Import\Repositories\EavAttributeRepositoryInterface $eavAttributeRepository The repository to access EAV attributes |
||
| 417 | * |
||
| 418 | * @return void |
||
| 419 | */ |
||
| 420 | public function setEavAttributeRepository(EavAttributeRepositoryInterface $eavAttributeRepository) |
||
| 424 | |||
| 425 | /** |
||
| 426 | * Return's the repository to access EAV attributes. |
||
| 427 | * |
||
| 428 | * @return \TechDivision\Import\Repositories\EavAttributeRepositoryInterface The repository instance |
||
| 429 | */ |
||
| 430 | public function getEavAttributeRepository() |
||
| 434 | |||
| 435 | /** |
||
| 436 | * Set's the repository to access EAV entity types. |
||
| 437 | * |
||
| 438 | * @param \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface $eavEntityTypeRepository The repository to access EAV entity types |
||
| 439 | * |
||
| 440 | * @return void |
||
| 441 | */ |
||
| 442 | public function setEavEntityTypeRepository(EavEntityTypeRepositoryInterface $eavEntityTypeRepository) |
||
| 446 | |||
| 447 | /** |
||
| 448 | * Return's the repository to access EAV entity types. |
||
| 449 | * |
||
| 450 | * @return \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface The repository instance |
||
| 451 | */ |
||
| 452 | public function getEavEntityTypeRepository() |
||
| 456 | |||
| 457 | /** |
||
| 458 | * Set's the action with the product CRUD methods. |
||
| 459 | * |
||
| 460 | * @param ActionInterface $productAction The action with the product CRUD methods |
||
| 461 | * |
||
| 462 | * @return void |
||
| 463 | */ |
||
| 464 | public function setProductAction(ActionInterface $productAction) |
||
| 468 | |||
| 469 | /** |
||
| 470 | * Return's the action with the product CRUD methods. |
||
| 471 | * |
||
| 472 | * @return ActionInterface The action instance |
||
| 473 | */ |
||
| 474 | public function getProductAction() |
||
| 478 | |||
| 479 | /** |
||
| 480 | * Set's the action with the product varchar attribute CRUD methods. |
||
| 481 | * |
||
| 482 | * @param ActionInterface $productVarcharAction The action with the product varchar attriute CRUD methods |
||
| 483 | * |
||
| 484 | * @return void |
||
| 485 | */ |
||
| 486 | public function setProductVarcharAction(ActionInterface $productVarcharAction) |
||
| 490 | |||
| 491 | /** |
||
| 492 | * Return's the action with the product varchar attribute CRUD methods. |
||
| 493 | * |
||
| 494 | * @return ActionInterface The action instance |
||
| 495 | */ |
||
| 496 | public function getProductVarcharAction() |
||
| 500 | |||
| 501 | /** |
||
| 502 | * Set's the action with the product text attribute CRUD methods. |
||
| 503 | * |
||
| 504 | * @param ActionInterface $productTextAction The action with the product text attriute CRUD methods |
||
| 505 | * |
||
| 506 | * @return void |
||
| 507 | */ |
||
| 508 | public function setProductTextAction(ActionInterface $productTextAction) |
||
| 512 | |||
| 513 | /** |
||
| 514 | * Return's the action with the product text attribute CRUD methods. |
||
| 515 | * |
||
| 516 | * @return ActionInterface The action instance |
||
| 517 | */ |
||
| 518 | public function getProductTextAction() |
||
| 522 | |||
| 523 | /** |
||
| 524 | * Set's the action with the product int attribute CRUD methods. |
||
| 525 | * |
||
| 526 | * @param ActionInterface $productIntAction The action with the product int attriute CRUD methods |
||
| 527 | * |
||
| 528 | * @return void |
||
| 529 | */ |
||
| 530 | public function setProductIntAction(ActionInterface $productIntAction) |
||
| 534 | |||
| 535 | /** |
||
| 536 | * Return's the action with the product int attribute CRUD methods. |
||
| 537 | * |
||
| 538 | * @return ActionInterface The action instance |
||
| 539 | */ |
||
| 540 | public function getProductIntAction() |
||
| 544 | |||
| 545 | /** |
||
| 546 | * Set's the action with the product decimal attribute CRUD methods. |
||
| 547 | * |
||
| 548 | * @param ActionInterface $productDecimalAction The action with the product decimal attriute CRUD methods |
||
| 549 | * |
||
| 550 | * @return void |
||
| 551 | */ |
||
| 552 | public function setProductDecimalAction(ActionInterface $productDecimalAction) |
||
| 556 | |||
| 557 | /** |
||
| 558 | * Return's the action with the product decimal attribute CRUD methods. |
||
| 559 | * |
||
| 560 | * @return ActionInterface The action instance |
||
| 561 | */ |
||
| 562 | public function getProductDecimalAction() |
||
| 566 | |||
| 567 | /** |
||
| 568 | * Set's the action with the product datetime attribute CRUD methods. |
||
| 569 | * |
||
| 570 | * @param ActionInterface $productDatetimeAction The action with the product datetime attriute CRUD methods |
||
| 571 | * |
||
| 572 | * @return void |
||
| 573 | */ |
||
| 574 | public function setProductDatetimeAction(ActionInterface $productDatetimeAction) |
||
| 578 | |||
| 579 | /** |
||
| 580 | * Return's the action with the product datetime attribute CRUD methods. |
||
| 581 | * |
||
| 582 | * @return ActionInterface The action instance |
||
| 583 | */ |
||
| 584 | public function getProductDatetimeAction() |
||
| 588 | |||
| 589 | /** |
||
| 590 | * Set's the action with the product website CRUD methods. |
||
| 591 | * |
||
| 592 | * @param ActionInterface $productWebsiteAction The action with the product website CRUD methods |
||
| 593 | * |
||
| 594 | * @return void |
||
| 595 | */ |
||
| 596 | public function setProductWebsiteAction(ActionInterface $productWebsiteAction) |
||
| 600 | |||
| 601 | /** |
||
| 602 | * Return's the action with the product website CRUD methods. |
||
| 603 | * |
||
| 604 | * @return ActionInterface The action instance |
||
| 605 | */ |
||
| 606 | public function getProductWebsiteAction() |
||
| 610 | |||
| 611 | /** |
||
| 612 | * Set's the action with the category product relation CRUD methods. |
||
| 613 | * |
||
| 614 | * @param ActionInterface $categoryProductAction The action with the category product relation CRUD methods |
||
| 615 | * |
||
| 616 | * @return void |
||
| 617 | */ |
||
| 618 | public function setCategoryProductAction(ActionInterface $categoryProductAction) |
||
| 622 | |||
| 623 | /** |
||
| 624 | * Return's the action with the category product relation CRUD methods. |
||
| 625 | * |
||
| 626 | * @return ActionInterface The action instance |
||
| 627 | */ |
||
| 628 | public function getCategoryProductAction() |
||
| 632 | |||
| 633 | /** |
||
| 634 | * Set's the action with the stock item CRUD methods. |
||
| 635 | * |
||
| 636 | * @param ActionInterface $stockItemAction The action with the stock item CRUD methods |
||
| 637 | * |
||
| 638 | * @return void |
||
| 639 | */ |
||
| 640 | public function setStockItemAction(ActionInterface $stockItemAction) |
||
| 644 | |||
| 645 | /** |
||
| 646 | * Return's the action with the stock item CRUD methods. |
||
| 647 | * |
||
| 648 | * @return ActionInterface The action instance |
||
| 649 | */ |
||
| 650 | public function getStockItemAction() |
||
| 654 | |||
| 655 | /** |
||
| 656 | * Set's the action with the URL rewrite CRUD methods. |
||
| 657 | * |
||
| 658 | * @param \TechDivision\Import\Actions\ActionInterface $urlRewriteAction The action with the URL rewrite CRUD methods |
||
| 659 | * |
||
| 660 | * @return void |
||
| 661 | */ |
||
| 662 | public function setUrlRewriteAction(ActionInterface $urlRewriteAction) |
||
| 666 | |||
| 667 | /** |
||
| 668 | * Return's the action with the URL rewrite CRUD methods. |
||
| 669 | * |
||
| 670 | * @return \TechDivision\Import\Actions\ActionInterface The action instance |
||
| 671 | */ |
||
| 672 | public function getUrlRewriteAction() |
||
| 676 | |||
| 677 | /** |
||
| 678 | * Set's the repository to load the products with. |
||
| 679 | * |
||
| 680 | * @param \TechDivision\Import\Product\Repositories\ProductRepositoryInterface $productRepository The repository instance |
||
| 681 | * |
||
| 682 | * @return void |
||
| 683 | */ |
||
| 684 | public function setProductRepository(ProductRepositoryInterface $productRepository) |
||
| 688 | |||
| 689 | /** |
||
| 690 | * Return's the repository to load the products with. |
||
| 691 | * |
||
| 692 | * @return \TechDivision\Import\Product\Repositories\ProductRepositoryInterface The repository instance |
||
| 693 | */ |
||
| 694 | public function getProductRepository() |
||
| 698 | |||
| 699 | /** |
||
| 700 | * Set's the repository to load the product website relations with. |
||
| 701 | * |
||
| 702 | * @param \TechDivision\Import\Product\Repositories\ProductWebsiteRepositoryInterface $productWebsiteRepository The repository instance |
||
| 703 | * |
||
| 704 | * @return void |
||
| 705 | */ |
||
| 706 | public function setProductWebsiteRepository(ProductWebsiteRepositoryInterface $productWebsiteRepository) |
||
| 710 | |||
| 711 | /** |
||
| 712 | * Return's the repository to load the product website relations with. |
||
| 713 | * |
||
| 714 | * @return \TechDivision\Import\Product\Repositories\ProductWebsiteRepositoryInterface The repository instance |
||
| 715 | */ |
||
| 716 | public function getProductWebsiteRepository() |
||
| 720 | |||
| 721 | /** |
||
| 722 | * Set's the repository to load the product datetime attribute with. |
||
| 723 | * |
||
| 724 | * @param \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface $productDatetimeRepository The repository instance |
||
| 725 | * |
||
| 726 | * @return void |
||
| 727 | */ |
||
| 728 | public function setProductDatetimeRepository(ProductDatetimeRepositoryInterface $productDatetimeRepository) |
||
| 732 | |||
| 733 | /** |
||
| 734 | * Return's the repository to load the product datetime attribute with. |
||
| 735 | * |
||
| 736 | * @return \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface The repository instance |
||
| 737 | */ |
||
| 738 | public function getProductDatetimeRepository() |
||
| 742 | |||
| 743 | /** |
||
| 744 | * Set's the repository to load the product decimal attribute with. |
||
| 745 | * |
||
| 746 | * @param \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface $productDecimalRepository The repository instance |
||
| 747 | * |
||
| 748 | * @return void |
||
| 749 | */ |
||
| 750 | public function setProductDecimalRepository(ProductDecimalRepositoryInterface $productDecimalRepository) |
||
| 754 | |||
| 755 | /** |
||
| 756 | * Return's the repository to load the product decimal attribute with. |
||
| 757 | * |
||
| 758 | * @return \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface The repository instance |
||
| 759 | */ |
||
| 760 | public function getProductDecimalRepository() |
||
| 764 | |||
| 765 | /** |
||
| 766 | * Set's the repository to load the product integer attribute with. |
||
| 767 | * |
||
| 768 | * @param \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface $productIntRepository The repository instance |
||
| 769 | * |
||
| 770 | * @return void |
||
| 771 | */ |
||
| 772 | public function setProductIntRepository(ProductIntRepositoryInterface $productIntRepository) |
||
| 776 | |||
| 777 | /** |
||
| 778 | * Return's the repository to load the product integer attribute with. |
||
| 779 | * |
||
| 780 | * @return \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface The repository instance |
||
| 781 | */ |
||
| 782 | public function getProductIntRepository() |
||
| 786 | |||
| 787 | /** |
||
| 788 | * Set's the repository to load the product text attribute with. |
||
| 789 | * |
||
| 790 | * @param \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface $productTextRepository The repository instance |
||
| 791 | * |
||
| 792 | * @return void |
||
| 793 | */ |
||
| 794 | public function setProductTextRepository(ProductTextRepositoryInterface $productTextRepository) |
||
| 798 | |||
| 799 | /** |
||
| 800 | * Return's the repository to load the product text attribute with. |
||
| 801 | * |
||
| 802 | * @return \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface The repository instance |
||
| 803 | */ |
||
| 804 | public function getProductTextRepository() |
||
| 808 | |||
| 809 | /** |
||
| 810 | * Set's the repository to load the product varchar attribute with. |
||
| 811 | * |
||
| 812 | * @param \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface $productVarcharRepository The repository instance |
||
| 813 | * |
||
| 814 | * @return void |
||
| 815 | */ |
||
| 816 | public function setProductVarcharRepository(ProductVarcharRepositoryInterface $productVarcharRepository) |
||
| 820 | |||
| 821 | /** |
||
| 822 | * Return's the repository to load the product varchar attribute with. |
||
| 823 | * |
||
| 824 | * @return \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface The repository instance |
||
| 825 | */ |
||
| 826 | public function getProductVarcharRepository() |
||
| 830 | |||
| 831 | /** |
||
| 832 | * Set's the repository to load the category product relations with. |
||
| 833 | * |
||
| 834 | * @param \TechDivision\Import\Product\Repositories\CategoryProductRepositoryInterface $categoryProductRepository The repository instance |
||
| 835 | * |
||
| 836 | * @return void |
||
| 837 | */ |
||
| 838 | public function setCategoryProductRepository(CategoryProductRepositoryInterface $categoryProductRepository) |
||
| 842 | |||
| 843 | /** |
||
| 844 | * Return's the repository to load the category product relations with. |
||
| 845 | * |
||
| 846 | * @return \TechDivision\Import\Product\Repositories\CategoryProductRepositoryInterface The repository instance |
||
| 847 | */ |
||
| 848 | public function getCategoryProductRepository() |
||
| 852 | |||
| 853 | /** |
||
| 854 | * Set's the repository to load the stock items with. |
||
| 855 | * |
||
| 856 | * @param \TechDivision\Import\Product\Repositories\StockItemRepositoryInterface $stockItemRepository The repository instance |
||
| 857 | * |
||
| 858 | * @return void |
||
| 859 | */ |
||
| 860 | public function setStockItemRepository(StockItemRepositoryInterface $stockItemRepository) |
||
| 864 | |||
| 865 | /** |
||
| 866 | * Return's the repository to load the stock items with. |
||
| 867 | * |
||
| 868 | * @return \TechDivision\Import\Product\Repositories\StockItemRepositoryInterface The repository instance |
||
| 869 | */ |
||
| 870 | public function getStockItemRepository() |
||
| 874 | |||
| 875 | /** |
||
| 876 | * Set's the assembler to load the product attributes with. |
||
| 877 | * |
||
| 878 | * @param \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface $productAttributeAssembler The assembler instance |
||
| 879 | * |
||
| 880 | * @return void |
||
| 881 | */ |
||
| 882 | public function setProductAttributeAssembler(ProductAttributeAssemblerInterface $productAttributeAssembler) |
||
| 886 | |||
| 887 | /** |
||
| 888 | * Return's the assembler to load the product attributes with. |
||
| 889 | * |
||
| 890 | * @return \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface The assembler instance |
||
| 891 | */ |
||
| 892 | public function getProductAttributeAssembler() |
||
| 896 | |||
| 897 | /** |
||
| 898 | * Return's an array with the available EAV attributes for the passed is user defined flag. |
||
| 899 | * |
||
| 900 | * @param integer $isUserDefined The flag itself |
||
| 901 | * |
||
| 902 | * @return array The array with the EAV attributes matching the passed flag |
||
| 903 | */ |
||
| 904 | public function getEavAttributeByIsUserDefined($isUserDefined = 1) |
||
| 908 | |||
| 909 | /** |
||
| 910 | * Return's the category product relations for the product with the passed SKU. |
||
| 911 | * |
||
| 912 | * @param string $sku The product SKU to load the category relations for |
||
| 913 | * |
||
| 914 | * @return array The category product relations for the product with the passed SKU |
||
| 915 | */ |
||
| 916 | public function getCategoryProductsBySku($sku) |
||
| 920 | |||
| 921 | /** |
||
| 922 | * Intializes the existing attributes for the entity with the passed primary key. |
||
| 923 | * |
||
| 924 | * @param string $pk The primary key of the entity to load the attributes for |
||
| 925 | * @param integer $storeId The ID of the store view to load the attributes for |
||
| 926 | * |
||
| 927 | * @return array The entity attributes |
||
| 928 | */ |
||
| 929 | public function getProductAttributesByPrimaryKeyAndStoreId($pk, $storeId) |
||
| 933 | |||
| 934 | /** |
||
| 935 | * Load's and return's a raw entity without primary key but the mandatory members only and nulled values. |
||
| 936 | * |
||
| 937 | * @param string $entityTypeCode The entity type code to return the raw entity for |
||
| 938 | * @param array $data An array with data that will be used to initialize the raw entity with |
||
| 939 | * |
||
| 940 | * @return array The initialized entity |
||
| 941 | */ |
||
| 942 | public function loadRawEntity($entityTypeCode, array $data = array()) |
||
| 946 | |||
| 947 | /** |
||
| 948 | * Load's and return's the EAV attribute option value with the passed entity type ID, code, store ID and value. |
||
| 949 | * |
||
| 950 | * @param string $entityTypeId The entity type ID of the EAV attribute to load the option value for |
||
| 951 | * @param string $attributeCode The code of the EAV attribute option to load |
||
| 952 | * @param integer $storeId The store ID of the attribute option to load |
||
| 953 | * @param string $value The value of the attribute option to load |
||
| 954 | * |
||
| 955 | * @return array The EAV attribute option value |
||
| 956 | */ |
||
| 957 | public function loadAttributeOptionValueByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value) |
||
| 961 | |||
| 962 | /** |
||
| 963 | * Load's and return's the available products. |
||
| 964 | * |
||
| 965 | * @return array The available products |
||
| 966 | */ |
||
| 967 | public function loadProducts() |
||
| 971 | |||
| 972 | /** |
||
| 973 | * Load's and return's the product with the passed SKU. |
||
| 974 | * |
||
| 975 | * @param string $sku The SKU of the product to load |
||
| 976 | * |
||
| 977 | * @return array The product |
||
| 978 | */ |
||
| 979 | public function loadProduct($sku) |
||
| 983 | |||
| 984 | /** |
||
| 985 | * Load's and return's the product website relation with the passed product and website ID. |
||
| 986 | * |
||
| 987 | * @param string $productId The product ID of the relation |
||
| 988 | * @param string $websiteId The website ID of the relation |
||
| 989 | * |
||
| 990 | * @return array The product website |
||
| 991 | */ |
||
| 992 | public function loadProductWebsite($productId, $websiteId) |
||
| 996 | |||
| 997 | /** |
||
| 998 | * Load's and return's the product website relations for the product with the passed SKU. |
||
| 999 | * |
||
| 1000 | * @param string $sku The SKU to of the product to load the product website relations for |
||
| 1001 | * |
||
| 1002 | * @return array The product website relations |
||
| 1003 | */ |
||
| 1004 | public function loadProductWebsitesBySku($sku) |
||
| 1008 | |||
| 1009 | /** |
||
| 1010 | * Return's the category product relation with the passed category/product ID. |
||
| 1011 | * |
||
| 1012 | * @param integer $categoryId The category ID of the category product relation to return |
||
| 1013 | * @param integer $productId The product ID of the category product relation to return |
||
| 1014 | * |
||
| 1015 | * @return array The category product relation |
||
| 1016 | */ |
||
| 1017 | public function loadCategoryProduct($categoryId, $productId) |
||
| 1021 | |||
| 1022 | /** |
||
| 1023 | * Load's and return's the stock status with the passed product/website/stock ID. |
||
| 1024 | * |
||
| 1025 | * @param integer $productId The product ID of the stock item to load |
||
| 1026 | * @param integer $websiteId The website ID of the stock item to load |
||
| 1027 | * @param integer $stockId The stock ID of the stock item to load |
||
| 1028 | * |
||
| 1029 | * @return array The stock item |
||
| 1030 | */ |
||
| 1031 | public function loadStockItem($productId, $websiteId, $stockId) |
||
| 1035 | |||
| 1036 | /** |
||
| 1037 | * Load's and return's the varchar attribute with the passed params. |
||
| 1038 | * |
||
| 1039 | * @param integer $attributeCode The attribute code of the varchar attribute |
||
| 1040 | * @param integer $entityTypeId The entity type ID of the varchar attribute |
||
| 1041 | * @param integer $storeId The store ID of the varchar attribute |
||
| 1042 | * @param string $value The value of the varchar attribute |
||
| 1043 | * |
||
| 1044 | * @return array|null The varchar attribute |
||
| 1045 | */ |
||
| 1046 | public function loadVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue($attributeCode, $entityTypeId, $storeId, $value) |
||
| 1050 | |||
| 1051 | /** |
||
| 1052 | * Load's and return's the varchar attribute with the passed params. |
||
| 1053 | * |
||
| 1054 | * @param integer $attributeCode The attribute code of the varchar attribute |
||
| 1055 | * @param integer $entityTypeId The entity type ID of the varchar attribute |
||
| 1056 | * @param integer $storeId The store ID of the varchar attribute |
||
| 1057 | * @param string $value The value of the varchar attribute |
||
| 1058 | * |
||
| 1059 | * @return array|null The varchar attribute |
||
| 1060 | */ |
||
| 1061 | public function loadProductVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue($attributeCode, $entityTypeId, $storeId, $value) |
||
| 1065 | |||
| 1066 | /** |
||
| 1067 | * Return's an EAV entity type with the passed entity type code. |
||
| 1068 | * |
||
| 1069 | * @param string $entityTypeCode The code of the entity type to return |
||
| 1070 | * |
||
| 1071 | * @return array The entity type with the passed entity type code |
||
| 1072 | */ |
||
| 1073 | public function loadEavEntityTypeByEntityTypeCode($entityTypeCode) |
||
| 1077 | |||
| 1078 | /** |
||
| 1079 | * Persist's the passed product data and return's the ID. |
||
| 1080 | * |
||
| 1081 | * @param array $product The product data to persist |
||
| 1082 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1083 | * |
||
| 1084 | * @return string The ID of the persisted entity |
||
| 1085 | */ |
||
| 1086 | public function persistProduct($product, $name = null) |
||
| 1090 | |||
| 1091 | /** |
||
| 1092 | * Persist's the passed product varchar attribute. |
||
| 1093 | * |
||
| 1094 | * @param array $attribute The attribute to persist |
||
| 1095 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1096 | * |
||
| 1097 | * @return string The ID of the persisted attribute |
||
| 1098 | */ |
||
| 1099 | public function persistProductVarcharAttribute($attribute, $name = null) |
||
| 1103 | |||
| 1104 | /** |
||
| 1105 | * Persist's the passed product integer attribute. |
||
| 1106 | * |
||
| 1107 | * @param array $attribute The attribute to persist |
||
| 1108 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1109 | * |
||
| 1110 | * @return void |
||
| 1111 | */ |
||
| 1112 | public function persistProductIntAttribute($attribute, $name = null) |
||
| 1116 | |||
| 1117 | /** |
||
| 1118 | * Persist's the passed product decimal attribute. |
||
| 1119 | * |
||
| 1120 | * @param array $attribute The attribute to persist |
||
| 1121 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1122 | * |
||
| 1123 | * @return void |
||
| 1124 | */ |
||
| 1125 | public function persistProductDecimalAttribute($attribute, $name = null) |
||
| 1129 | |||
| 1130 | /** |
||
| 1131 | * Persist's the passed product datetime attribute. |
||
| 1132 | * |
||
| 1133 | * @param array $attribute The attribute to persist |
||
| 1134 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1135 | * |
||
| 1136 | * @return void |
||
| 1137 | */ |
||
| 1138 | public function persistProductDatetimeAttribute($attribute, $name = null) |
||
| 1142 | |||
| 1143 | /** |
||
| 1144 | * Persist's the passed product text attribute. |
||
| 1145 | * |
||
| 1146 | * @param array $attribute The attribute to persist |
||
| 1147 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1148 | * |
||
| 1149 | * @return void |
||
| 1150 | */ |
||
| 1151 | public function persistProductTextAttribute($attribute, $name = null) |
||
| 1155 | |||
| 1156 | /** |
||
| 1157 | * Persist's the passed product website data and return's the ID. |
||
| 1158 | * |
||
| 1159 | * @param array $productWebsite The product website data to persist |
||
| 1160 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1161 | * |
||
| 1162 | * @return void |
||
| 1163 | */ |
||
| 1164 | public function persistProductWebsite($productWebsite, $name = null) |
||
| 1168 | |||
| 1169 | /** |
||
| 1170 | * Persist's the passed category product relation. |
||
| 1171 | * |
||
| 1172 | * @param array $categoryProduct The category product relation to persist |
||
| 1173 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1174 | * |
||
| 1175 | * @return void |
||
| 1176 | */ |
||
| 1177 | public function persistCategoryProduct($categoryProduct, $name = null) |
||
| 1181 | |||
| 1182 | /** |
||
| 1183 | * Persist's the passed stock item data and return's the ID. |
||
| 1184 | * |
||
| 1185 | * @param array $stockItem The stock item data to persist |
||
| 1186 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1187 | * |
||
| 1188 | * @return void |
||
| 1189 | */ |
||
| 1190 | public function persistStockItem($stockItem, $name = null) |
||
| 1194 | |||
| 1195 | /** |
||
| 1196 | * Delete's the entity with the passed attributes. |
||
| 1197 | * |
||
| 1198 | * @param array $row The attributes of the entity to delete |
||
| 1199 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1200 | * |
||
| 1201 | * @return void |
||
| 1202 | */ |
||
| 1203 | public function deleteProduct($row, $name = null) |
||
| 1207 | |||
| 1208 | /** |
||
| 1209 | * Delete's the URL rewrite with the passed attributes. |
||
| 1210 | * |
||
| 1211 | * @param array $row The attributes of the entity to delete |
||
| 1212 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1213 | * |
||
| 1214 | * @return void |
||
| 1215 | */ |
||
| 1216 | public function deleteUrlRewrite($row, $name = null) |
||
| 1220 | |||
| 1221 | /** |
||
| 1222 | * Delete's the stock item(s) with the passed attributes. |
||
| 1223 | * |
||
| 1224 | * @param array $row The attributes of the entity to delete |
||
| 1225 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1226 | * |
||
| 1227 | * @return void |
||
| 1228 | */ |
||
| 1229 | public function deleteStockItem($row, $name = null) |
||
| 1233 | |||
| 1234 | /** |
||
| 1235 | * Delete's the product website relations with the passed attributes. |
||
| 1236 | * |
||
| 1237 | * @param array $row The attributes of the entity to delete |
||
| 1238 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1239 | * |
||
| 1240 | * @return void |
||
| 1241 | */ |
||
| 1242 | public function deleteProductWebsite($row, $name = null) |
||
| 1246 | |||
| 1247 | /** |
||
| 1248 | * Delete's the category product relations with the passed attributes. |
||
| 1249 | * |
||
| 1250 | * @param array $row The attributes of the entity to delete |
||
| 1251 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1252 | * |
||
| 1253 | * @return void |
||
| 1254 | */ |
||
| 1255 | public function deleteCategoryProduct($row, $name = null) |
||
| 1259 | |||
| 1260 | /** |
||
| 1261 | * Delete's the product datetime attribute with the passed attributes. |
||
| 1262 | * |
||
| 1263 | * @param array $row The attributes of the entity to delete |
||
| 1264 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1265 | * |
||
| 1266 | * @return void |
||
| 1267 | */ |
||
| 1268 | public function deleteProductDatetimeAttribute($row, $name = null) |
||
| 1272 | |||
| 1273 | /** |
||
| 1274 | * Delete's the product decimal attribute with the passed attributes. |
||
| 1275 | * |
||
| 1276 | * @param array $row The attributes of the entity to delete |
||
| 1277 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1278 | * |
||
| 1279 | * @return void |
||
| 1280 | */ |
||
| 1281 | public function deleteProductDecimalAttribute($row, $name = null) |
||
| 1285 | |||
| 1286 | /** |
||
| 1287 | * Delete's the product integer attribute with the passed attributes. |
||
| 1288 | * |
||
| 1289 | * @param array $row The attributes of the entity to delete |
||
| 1290 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1291 | * |
||
| 1292 | * @return void |
||
| 1293 | */ |
||
| 1294 | public function deleteProductIntAttribute($row, $name = null) |
||
| 1298 | |||
| 1299 | /** |
||
| 1300 | * Delete's the product text attribute with the passed attributes. |
||
| 1301 | * |
||
| 1302 | * @param array $row The attributes of the entity to delete |
||
| 1303 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1304 | * |
||
| 1305 | * @return void |
||
| 1306 | */ |
||
| 1307 | public function deleteProductTextAttribute($row, $name = null) |
||
| 1311 | |||
| 1312 | /** |
||
| 1313 | * Delete's the product varchar attribute with the passed attributes. |
||
| 1314 | * |
||
| 1315 | * @param array $row The attributes of the entity to delete |
||
| 1316 | * @param string|null $name The name of the prepared statement that has to be executed |
||
| 1317 | * |
||
| 1318 | * @return void |
||
| 1319 | */ |
||
| 1320 | public function deleteProductVarcharAttribute($row, $name = null) |
||
| 1324 | |||
| 1325 | /** |
||
| 1326 | * Clean-Up the repositories to free memory. |
||
| 1327 | * |
||
| 1328 | * @return void |
||
| 1329 | */ |
||
| 1330 | public function cleanUp() |
||
| 1333 | } |
||
| 1334 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: